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