]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c
ShellParametersProtocol - remove parsing from within quoted parameters.
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel1CommandsLib / Shift.c
CommitLineData
a405b86d 1/** @file\r
2 Main file for Shift shell level 1 function.\r
3\r
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "UefiShellLevel1CommandsLib.h"\r
16\r
17/**\r
18 Function for 'shift' command.\r
19\r
20 @param[in] ImageHandle Handle to the Image (NULL if Internal).\r
21 @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r
22**/\r
23SHELL_STATUS\r
24EFIAPI\r
25ShellCommandRunShift (\r
26 IN EFI_HANDLE ImageHandle,\r
27 IN EFI_SYSTEM_TABLE *SystemTable\r
28 )\r
29{\r
30 EFI_STATUS Status;\r
31 SCRIPT_FILE *CurrentScriptFile;\r
32 UINTN LoopVar;\r
33\r
34 Status = CommandInit();\r
35 ASSERT_EFI_ERROR(Status);\r
36\r
37 if (!gEfiShellProtocol->BatchIsActive()) {\r
38 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"Shift");\r
39 return (SHELL_UNSUPPORTED);\r
40 }\r
41\r
42 CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r
43 ASSERT(CurrentScriptFile != NULL);\r
44\r
45 if (CurrentScriptFile->Argc < 2) {\r
46 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle);\r
47 return (SHELL_UNSUPPORTED);\r
48 }\r
49\r
50 for (LoopVar = 0 ; LoopVar < CurrentScriptFile->Argc ; LoopVar++) {\r
51 if (LoopVar == 0) {\r
52 SHELL_FREE_NON_NULL(CurrentScriptFile->Argv[LoopVar]);\r
53 }\r
54 if (LoopVar < CurrentScriptFile->Argc -1) {\r
55 CurrentScriptFile->Argv[LoopVar] = CurrentScriptFile->Argv[LoopVar+1];\r
56 } else {\r
57 CurrentScriptFile->Argv[LoopVar] = NULL;\r
58 }\r
59 }\r
60 CurrentScriptFile->Argc--;\r
61 return (SHELL_SUCCESS);\r
62}\r
63\r