2 Main file for exit shell level 1 function.
4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2009 - 2011, 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"
18 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
24 Function for 'exit' command.
26 @param[in] ImageHandle Handle to the Image (NULL if Internal).
27 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
32 IN EFI_HANDLE ImageHandle
,
33 IN EFI_SYSTEM_TABLE
*SystemTable
39 SHELL_STATUS ShellStatus
;
43 ShellStatus
= SHELL_SUCCESS
;
46 // initialize the shell lib (we must be in non-auto-init...)
48 Status
= ShellInitialize();
49 ASSERT_EFI_ERROR(Status
);
51 Status
= CommandInit();
52 ASSERT_EFI_ERROR(Status
);
55 // parse the command line
57 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
58 if (EFI_ERROR(Status
)) {
59 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
60 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel1HiiHandle
, L
"exit", ProblemParam
);
61 FreePool(ProblemParam
);
62 ShellStatus
= SHELL_INVALID_PARAMETER
;
69 // return the specified error code
71 Return
= ShellCommandLineGetRawValue(Package
, 1);
73 Status
= ShellConvertStringToUint64(Return
, &RetVal
, FALSE
, FALSE
);
74 if (EFI_ERROR(Status
)) {
75 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellLevel1HiiHandle
, L
"exit", Return
);
76 ShellStatus
= SHELL_INVALID_PARAMETER
;
79 // If we are in a batch file and /b then pass TRUE otherwise false...
81 ShellCommandRegisterExit((BOOLEAN
)(gEfiShellProtocol
->BatchIsActive() && ShellCommandLineGetFlag(Package
, L
"/b")), RetVal
);
83 ShellStatus
= SHELL_SUCCESS
;
86 // If we are in a batch file and /b then pass TRUE otherwise false...
88 ShellCommandRegisterExit((BOOLEAN
)(gEfiShellProtocol
->BatchIsActive() && ShellCommandLineGetFlag(Package
, L
"/b")), 0);
90 ShellStatus
= SHELL_SUCCESS
;
93 ShellCommandLineFreeVarList (Package
);