From e3eb7d825adae351f1a45e7809c8506b364ee059 Mon Sep 17 00:00:00 2001 From: Jaben Carsey Date: Thu, 19 Dec 2013 21:55:13 +0000 Subject: 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 Reviewed-by: Erik Bjorge git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15008 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Application/Shell/Shell.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'ShellPkg/Application') diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c index fe722e9554..5e3af1d056 100644 --- a/ShellPkg/Application/Shell/Shell.c +++ b/ShellPkg/Application/Shell/Shell.c @@ -1840,8 +1840,19 @@ RunInternalCommand( // 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 @@ RunInternalCommand( // 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; } -- cgit v1.2.3