From 8a3146d46cea07829a0948f0848db04784541cea Mon Sep 17 00:00:00 2001 From: Tapan Shah Date: Fri, 29 Aug 2014 20:24:58 +0000 Subject: [PATCH] =?utf8?q?Add=20CTRL+C=20support=20for=20=E2=80=98ls?= =?utf8?q?=E2=80=99=20command.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Tapan Shah Reviewed-By: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15989 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/UefiShellLevel2CommandsLib/Ls.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c index 64ce4ae2c0..523096ac22 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c @@ -1,7 +1,7 @@ /** @file Main file for ls shell level 2 function. - Copyright (c) 2013 Hewlett-Packard Development Company, L.P. + Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -408,6 +408,10 @@ PrintLsOutput( ; !IsNull(&ListHead->Link, &Node->Link) ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link) ){ + if (ShellGetExecutionBreakFlag ()) { + ShellStatus = SHELL_ABORTED; + break; + } ASSERT(Node != NULL); if (LongestPath < StrSize(Node->FullName)) { LongestPath = StrSize(Node->FullName); @@ -445,12 +449,12 @@ PrintLsOutput( HeaderPrinted = TRUE; } - if (!Sfo) { + if (!Sfo && ShellStatus != SHELL_ABORTED) { PrintNonSfoFooter(FileCount, FileSize, DirCount); } } - if (Rec) { + if (Rec && ShellStatus != SHELL_ABORTED) { // // Re-Open all the files under the starting path for directories that didnt necessarily match our file filter // @@ -493,6 +497,13 @@ PrintLsOutput( &FoundOne, Count, TimeZone); + + // + // Since it's running recursively, we have to break immediately when returned SHELL_ABORTED + // + if (ShellStatus == SHELL_ABORTED) { + break; + } } } } -- 2.39.2