Revision: 15008
          http://sourceforge.net/p/edk2/code/15008
Author:   jcarsey
Date:     2013-12-19 21:55:13 +0000 (Thu, 19 Dec 2013)
Log Message:
-----------
ShellPkg: CTRL-C stops a running script at the same time

This makes CTRL-C stop a running script after trying to stop the command.  And 
adds comments to describe the behavior more clearly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <[email protected]>
Reviewed-by: Erik Bjorge <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ShellPkg/Application/Shell/Shell.c

Modified: trunk/edk2/ShellPkg/Application/Shell/Shell.c
===================================================================
--- trunk/edk2/ShellPkg/Application/Shell/Shell.c       2013-12-19 16:05:34 UTC 
(rev 15007)
+++ trunk/edk2/ShellPkg/Application/Shell/Shell.c       2013-12-19 21:55:13 UTC 
(rev 15008)
@@ -1840,9 +1840,20 @@
       // Pass thru the exitcode from the app.
       //
       if (ShellCommandGetExit()) {
+        //
+        // An Exit was requested ("exit" command), pass its value up.
+        //
         Status = CommandReturnedStatus;
-      } else if (CommandReturnedStatus != 0 && 
IsScriptOnlyCommand(FirstParameter)) {
+      } else if (CommandReturnedStatus != SHELL_SUCCESS && 
IsScriptOnlyCommand(FirstParameter)) {
+        //
+        // Always abort when a script only command fails for any reason
+        //
         Status = EFI_ABORTED;
+      } else if (ShellCommandGetCurrentScriptFile() != NULL && 
CommandReturnedStatus == SHELL_ABORTED) {
+        //
+        // Abort when in a script and a command aborted
+        //
+        Status = EFI_ABORTED;
       }
     }
   }
@@ -1853,11 +1864,17 @@
   //
   RestoreArgcArgv(ParamProtocol, &Argv, &Argc);
 
-  if (ShellCommandGetCurrentScriptFile() != NULL &&  
!IsScriptOnlyCommand(FirstParameter)) {
-    //
-    // if this is NOT a scipt only command return success so the script won't 
quit.
-    // prevent killing the script - this is the only place where we know the 
actual command name (after alias and variable replacement...)
-    //
+  //
+  // If a script is running and the command is not a scipt only command, then
+  // change return value to success so the script won't halt (unless aborted).
+  //
+  // Script only commands have to be able halt the script since the script will
+  // not operate if they are failing.
+  //
+  if ( ShellCommandGetCurrentScriptFile() != NULL
+    && !IsScriptOnlyCommand(FirstParameter)
+    && Status != EFI_ABORTED
+    ) {
     Status = EFI_SUCCESS;
   }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to