2 Main file for Shift shell level 1 function.
4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "UefiShellLevel1CommandsLib.h"
19 Function for 'shift' command.
21 @param[in] ImageHandle Handle to the Image (NULL if Internal).
22 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
26 ShellCommandRunShift (
27 IN EFI_HANDLE ImageHandle
,
28 IN EFI_SYSTEM_TABLE
*SystemTable
32 SCRIPT_FILE
*CurrentScriptFile
;
35 Status
= CommandInit();
36 ASSERT_EFI_ERROR(Status
);
38 if (!gEfiShellProtocol
->BatchIsActive()) {
39 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_NO_SCRIPT
), gShellLevel1HiiHandle
, L
"shift");
40 return (SHELL_UNSUPPORTED
);
43 CurrentScriptFile
= ShellCommandGetCurrentScriptFile();
44 ASSERT(CurrentScriptFile
!= NULL
);
46 if (CurrentScriptFile
->Argc
< 2) {
47 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellLevel1HiiHandle
, L
"shift");
48 return (SHELL_UNSUPPORTED
);
51 for (LoopVar
= 0 ; LoopVar
< CurrentScriptFile
->Argc
; LoopVar
++) {
53 SHELL_FREE_NON_NULL(CurrentScriptFile
->Argv
[LoopVar
]);
55 if (LoopVar
< CurrentScriptFile
->Argc
-1) {
56 CurrentScriptFile
->Argv
[LoopVar
] = CurrentScriptFile
->Argv
[LoopVar
+1];
58 CurrentScriptFile
->Argv
[LoopVar
] = NULL
;
61 CurrentScriptFile
->Argc
--;
62 return (SHELL_SUCCESS
);