From 3877d0f581536430fffe572ec3ceea29e0d50602 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Fri, 24 Jan 2014 22:31:07 +0000 Subject: [PATCH] ShellPkg/UefiShellLib.c: Execute: Return a Command status even in the old shell This means we can use ShellExecute without thinking which shell environment is in use. However it still isn't ideal: if mEfiShellEnvironment2->Execute returns EFI_INVALID_PARAMETER, we can't tell whether Execute() received an invalid parameter (e.g. ParentImageHandle was NULL), or whether we tried to execute a command with an invalid parameter (for example CommandLine "ls -hurdygurdy"). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brendan Jackman Reviewed-by: Olivier Martin Reviewed-by: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15183 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 12c6ea8380..e30e5c7dd1 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -1175,7 +1175,7 @@ ShellSetEnvironmentVariable ( The CommandLine is executed from the current working directory on the current device. - The EnvironmentVariables and Status parameters are ignored in a pre-UEFI Shell 2.0 + The EnvironmentVariables pararemeter is ignored in a pre-UEFI Shell 2.0 environment. The values pointed to by the parameters will be unchanged by the ShellExecute() function. The Output parameter has no effect in a UEFI Shell 2.0 environment. @@ -1203,6 +1203,7 @@ ShellExecute ( OUT EFI_STATUS *Status OPTIONAL ) { + EFI_STATUS CmdStatus; // // Check for UEFI Shell 2.0 protocols // @@ -1221,16 +1222,29 @@ ShellExecute ( // if (mEfiShellEnvironment2 != NULL) { // - // Call EFI Shell version (not using EnvironmentVariables or Status parameters) + // Call EFI Shell version. // Due to oddity in the EFI shell we want to dereference the ParentHandle here // - return (mEfiShellEnvironment2->Execute(*ParentHandle, + CmdStatus = (mEfiShellEnvironment2->Execute(*ParentHandle, CommandLine, Output)); + // + // No Status output parameter so just use the returned status + // + if (Status != NULL) { + *Status = CmdStatus; + } + // + // If there was an error, we can't tell if it was from the command or from + // the Execute() function, so we'll just assume the shell ran successfully + // and the error came from the command. + // + return EFI_SUCCESS; } return (EFI_UNSUPPORTED); } + /** Retreives the current directory path -- 2.39.2