DEBUG_CODE(ShellInfoObject.ConsoleInfo = NULL;);\r
}\r
\r
+ if (ShellCommandGetExit()) {\r
+ return ((EFI_STATUS)ShellCommandGetExitCode());\r
+ }\r
return (Status);\r
}\r
\r
BOOLEAN PreCommandEchoState;\r
CONST CHAR16 *CurDir;\r
UINTN LineCount;\r
+ CHAR16 LeString[50];\r
\r
ASSERT(!ShellCommandGetScriptExit());\r
\r
}\r
\r
if (ShellCommandGetScriptExit()) {\r
- ShellCommandRegisterExit(FALSE);\r
+ UnicodeSPrint(LeString, sizeof(LeString)*sizeof(LeString[0]), L"0x%Lx", ShellCommandGetExitCode());\r
+ DEBUG_CODE(InternalEfiShellSetEnv(L"DebugLasterror", LeString, TRUE););\r
+ InternalEfiShellSetEnv(L"Lasterror", LeString, TRUE);\r
+\r
+ ShellCommandRegisterExit(FALSE, 0);\r
Status = EFI_SUCCESS;\r
break;\r
}\r
Indicate that the current shell or script should exit.\r
\r
@param[in] ScriptOnly TRUE if exiting a script; FALSE otherwise.\r
+ @param[in] ErrorCode The 64 bit error code to return.\r
**/\r
VOID\r
EFIAPI\r
ShellCommandRegisterExit (\r
- IN BOOLEAN ScriptOnly\r
+ IN BOOLEAN ScriptOnly,\r
+ IN CONST UINT64 ErrorCode\r
+ );\r
+\r
+/**\r
+ Retrieve the Exit code.\r
+\r
+ @return the value passed into RegisterExit.\r
+**/\r
+UINT64\r
+EFIAPI\r
+ShellCommandGetExitCode (\r
+ VOID\r
);\r
\r
/**\r
STATIC ALIAS_LIST mAliasList;\r
STATIC BOOLEAN mEchoState;\r
STATIC BOOLEAN mExitRequested;\r
+STATIC UINT64 mExitCode;\r
STATIC BOOLEAN mExitScript;\r
STATIC CHAR16 *mProfileList;\r
STATIC UINTN mProfileListSize;\r
/**\r
Indicate that the current shell or script should exit.\r
\r
- @param[in] ScriptOnly TRUE if only exiting a script, FALSE othrwise.\r
+ @param[in] ScriptOnly TRUE if exiting a script; FALSE otherwise.\r
+ @param[in] ErrorCode The 64 bit error code to return.\r
**/\r
VOID\r
EFIAPI\r
ShellCommandRegisterExit (\r
- IN BOOLEAN ScriptOnly\r
+ IN BOOLEAN ScriptOnly,\r
+ IN CONST UINT64 ErrorCode\r
)\r
{\r
mExitRequested = (BOOLEAN)(!mExitRequested);\r
} else {\r
mExitScript = FALSE;\r
}\r
+ mExitCode = ErrorCode;\r
}\r
\r
/**\r
return (mExitRequested);\r
}\r
\r
+/**\r
+ Retrieve the Exit code.\r
+\r
+ If ShellCommandGetExit returns FALSE than the return from this is undefined.\r
+\r
+ @return the value passed into RegisterExit.\r
+**/\r
+UINT64\r
+EFIAPI\r
+ShellCommandGetExitCode (\r
+ VOID\r
+ )\r
+{\r
+ return (mExitCode);\r
+}\r
/**\r
Retrieve the Exit script indicator.\r
\r
//\r
// If we are in a batch file and /b then pass TRUE otherwise false...\r
//\r
- ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")));\r
+ ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")), RetVal);\r
\r
- ShellStatus = (SHELL_STATUS)(RetVal);\r
+ ShellStatus = SHELL_SUCCESS;\r
}\r
} else {\r
// If we are in a batch file and /b then pass TRUE otherwise false...\r
//\r
- ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")));\r
+ ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")), 0);\r
\r
- ShellStatus = (SHELL_STATUS)0;\r
+ ShellStatus = SHELL_SUCCESS;\r
}\r
\r
ShellCommandLineFreeVarList (Package);\r
}\r
\r
if (EFI_ERROR(Status) || Resp == NULL || *Resp == ShellPromptResponseQuit) {\r
- ShellCommandRegisterExit(TRUE);\r
+ ShellCommandRegisterExit(TRUE, 0);\r
ShellStatus = SHELL_ABORTED;\r
}\r
\r