]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Do not mix status when executing a command
authorOlivier Martin <olivier.martin@arm.com>
Tue, 13 May 2014 21:16:42 +0000 (21:16 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 13 May 2014 21:16:42 +0000 (21:16 +0000)
The function InternalShellExecuteDevicePath() did not differentiate an error occuring during the preparation of an image and an error occurring during its execution.

A use case of the issue was when a EFI application was called in a EFI Shell script. If the EFI application was returning an error then the NSH script stopped its execution. While the EFI Shell specification says the script should continue its execution (see 4.2 Error Handling).

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
Reviewed-by: Jaben Carsey <Jaben.Carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15523 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/Shell.c
ShellPkg/Application/Shell/ShellProtocol.c
ShellPkg/Application/Shell/ShellProtocol.h

index 056d66d09ee6a539b76999e792839f802e8d1e80..951d31e82bcd84a3b0ec181825c69430fdbdd85c 100644 (file)
@@ -2231,6 +2231,7 @@ RunCommandOrFile(
 )\r
 {\r
   EFI_STATUS                Status;\r
+  EFI_STATUS                StartStatus;\r
   CHAR16                    *CommandWithPath;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
   SHELL_STATUS              CalleeExitStatus;\r
@@ -2308,6 +2309,7 @@ RunCommandOrFile(
             DevPath,\r
             CmdLine,\r
             NULL,\r
+            &StartStatus,\r
             NULL,\r
             NULL\r
            );\r
@@ -2317,7 +2319,7 @@ RunCommandOrFile(
           if(EFI_ERROR (Status)) {\r
             CalleeExitStatus = (SHELL_STATUS) (Status & (~MAX_BIT));\r
           } else {\r
-            CalleeExitStatus = SHELL_SUCCESS;\r
+            CalleeExitStatus = (SHELL_STATUS) StartStatus;\r
           }\r
 \r
           //\r
index ec4559480d86c233307b8d510b0507307cf06f73..cfe2f409e4af6224e6b2c207fee1ce65dd2c9fb8 100644 (file)
@@ -1386,11 +1386,13 @@ InternalShellExecuteDevicePath(
   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
   IN CONST CHAR16                   *CommandLine OPTIONAL,\r
   IN CONST CHAR16                   **Environment OPTIONAL,\r
+  OUT EFI_STATUS                    *StartImageStatus OPTIONAL,\r
   OUT UINTN                         *ExitDataSize OPTIONAL,\r
   OUT CHAR16                        **ExitData OPTIONAL\r
   )\r
 {\r
   EFI_STATUS                    Status;\r
+  EFI_STATUS                    StartStatus;\r
   EFI_STATUS                    CleanupStatus;\r
   EFI_HANDLE                    NewHandle;\r
   EFI_LOADED_IMAGE_PROTOCOL     *LoadedImage;\r
@@ -1504,11 +1506,14 @@ InternalShellExecuteDevicePath(
     // now start the image, passing up exit data if the caller requested it\r
     //\r
     if (!EFI_ERROR(Status)) {\r
-      Status      = gBS->StartImage(\r
+      StartStatus      = gBS->StartImage(\r
                           NewHandle,\r
                           ExitDataSizePtr,\r
                           ExitData\r
                           );\r
+      if (StartImageStatus != NULL) {\r
+        *StartImageStatus = StartStatus;\r
+      }\r
 \r
       CleanupStatus = gBS->UninstallProtocolInterface(\r
                             NewHandle,\r
@@ -1620,6 +1625,7 @@ EfiShellExecute(
     DevPath,\r
     Temp,\r
     (CONST CHAR16**)Environment,\r
+    StatusCode,\r
     &ExitDataSize,\r
     &ExitData);\r
 \r
@@ -1644,8 +1650,6 @@ EfiShellExecute(
       }\r
       FreePool (ExitData);\r
       Status = EFI_SUCCESS;\r
-    } else if ((StatusCode != NULL) && !EFI_ERROR(Status)) {\r
-      *StatusCode = EFI_SUCCESS;\r
     }\r
 \r
   //\r
index ff123277c22951663044b0e2d04d36aaaacb73dd..7cc1b019471ac57a47777db3991af80500b3615c 100644 (file)
@@ -455,10 +455,11 @@ EfiShellEnablePageBreak (
 EFI_STATUS\r
 EFIAPI\r
 InternalShellExecuteDevicePath(\r
-  IN CONST EFI_HANDLE *ParentImageHandle,\r
+  IN CONST EFI_HANDLE               *ParentImageHandle,\r
   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
-  IN CONST CHAR16 *CommandLine OPTIONAL,\r
-  IN CONST CHAR16 **Environment OPTIONAL,\r
+  IN CONST CHAR16                   *CommandLine OPTIONAL,\r
+  IN CONST CHAR16                   **Environment OPTIONAL,\r
+  OUT EFI_STATUS                    *StartImageStatus OPTIONAL,\r
   OUT UINTN                         *ExitDataSize OPTIONAL,\r
   OUT CHAR16                        **ExitData OPTIONAL\r
   );\r