]>
Commit | Line | Data |
---|---|---|
a405b86d | 1 | /** @file\r |
2 | Main file for Shift shell level 1 function.\r | |
3 | \r | |
c011b6c9 | 4 | (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r |
ba0014b9 | 5 | Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r |
56ba3746 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
a405b86d | 7 | \r |
8 | **/\r | |
9 | \r | |
10 | #include "UefiShellLevel1CommandsLib.h"\r | |
11 | \r | |
12 | /**\r | |
13 | Function for 'shift' command.\r | |
14 | \r | |
15 | @param[in] ImageHandle Handle to the Image (NULL if Internal).\r | |
16 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r | |
17 | **/\r | |
18 | SHELL_STATUS\r | |
19 | EFIAPI\r | |
20 | ShellCommandRunShift (\r | |
21 | IN EFI_HANDLE ImageHandle,\r | |
22 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
23 | )\r | |
24 | {\r | |
47d20b54 MK |
25 | EFI_STATUS Status;\r |
26 | SCRIPT_FILE *CurrentScriptFile;\r | |
27 | UINTN LoopVar;\r | |
a405b86d | 28 | \r |
47d20b54 MK |
29 | Status = CommandInit ();\r |
30 | ASSERT_EFI_ERROR (Status);\r | |
a405b86d | 31 | \r |
47d20b54 MK |
32 | if (!gEfiShellProtocol->BatchIsActive ()) {\r |
33 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"shift");\r | |
a405b86d | 34 | return (SHELL_UNSUPPORTED);\r |
35 | }\r | |
36 | \r | |
47d20b54 MK |
37 | CurrentScriptFile = ShellCommandGetCurrentScriptFile ();\r |
38 | ASSERT (CurrentScriptFile != NULL);\r | |
a405b86d | 39 | \r |
40 | if (CurrentScriptFile->Argc < 2) {\r | |
47d20b54 | 41 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"shift");\r |
a405b86d | 42 | return (SHELL_UNSUPPORTED);\r |
43 | }\r | |
44 | \r | |
47d20b54 | 45 | for (LoopVar = 0; LoopVar < CurrentScriptFile->Argc; LoopVar++) {\r |
a405b86d | 46 | if (LoopVar == 0) {\r |
47d20b54 | 47 | SHELL_FREE_NON_NULL (CurrentScriptFile->Argv[LoopVar]);\r |
a405b86d | 48 | }\r |
47d20b54 | 49 | \r |
a405b86d | 50 | if (LoopVar < CurrentScriptFile->Argc -1) {\r |
51 | CurrentScriptFile->Argv[LoopVar] = CurrentScriptFile->Argv[LoopVar+1];\r | |
52 | } else {\r | |
53 | CurrentScriptFile->Argv[LoopVar] = NULL;\r | |
54 | }\r | |
55 | }\r | |
47d20b54 | 56 | \r |
a405b86d | 57 | CurrentScriptFile->Argc--;\r |
58 | return (SHELL_SUCCESS);\r | |
59 | }\r |