summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorJaben Carsey <jaben.carsey@intel.com>2013-12-10 18:41:35 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2013-12-10 18:41:35 +0000
commit19a4497259a24d0b9838c7e79c9ec4f5baf9828e (patch)
tree174f90799ba8c225ac29a94be8b56043c1ccd939 /ShellPkg
parentb2ce4a396135c666e613d3608f342c217c62750e (diff)
downloadedk2-platforms-19a4497259a24d0b9838c7e79c9ec4f5baf9828e.tar.xz
ShellPkg: Refactor Pipe handling
This moves some logic for handling command lines with pipe ‘|’ into a separate function. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14958 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Application/Shell/Shell.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c
index 84b74ea1d2..369789a3d7 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -71,6 +71,34 @@ STATIC CONST CHAR16 mExecutableExtensions[] = L".NSH;.EFI";
STATIC CONST CHAR16 mStartupScript[] = L"startup.nsh";
/**
+ Determine if a command line contains a valid split operation
+
+ @param[in] CmdLine The command line to parse.
+
+ @retval TRUE CmdLine has a valid split.
+ @retval FALSE CmdLine does not have a valid split.
+**/
+BOOLEAN
+EFIAPI
+ContainsSplit(
+ IN CONST CHAR16 *CmdLine
+ )
+{
+ CONST CHAR16 *TempSpot;
+ TempSpot = NULL;
+ if (StrStr(CmdLine, L"|") != NULL) {
+ for (TempSpot = CmdLine ; TempSpot != NULL && *TempSpot != CHAR_NULL ; TempSpot++) {
+ if (*TempSpot == L'^' && *(TempSpot+1) == L'|') {
+ TempSpot++;
+ } else if (*TempSpot == L'|') {
+ break;
+ }
+ }
+ }
+ return (TempSpot != NULL && *TempSpot != CHAR_NULL);
+}
+
+/**
Function to start monitoring for CTRL-S using SimpleTextInputEx. This
feature's enabled state was not known when the shell initially launched.
@@ -1389,7 +1417,6 @@ RunCommand(
SHELL_FILE_HANDLE OriginalStdOut;
SHELL_FILE_HANDLE OriginalStdErr;
SYSTEM_TABLE_INFO OriginalSystemTableInfo;
- CHAR16 *TempLocation3;
UINTN Count;
UINTN Count2;
CHAR16 *CleanOriginal;
@@ -1494,17 +1521,7 @@ RunCommand(
//
// We dont do normal processing with a split command line (output from one command input to another)
//
- TempLocation3 = NULL;
- if (StrStr(PostVariableCmdLine, L"|") != NULL) {
- for (TempLocation3 = PostVariableCmdLine ; TempLocation3 != NULL && *TempLocation3 != CHAR_NULL ; TempLocation3++) {
- if (*TempLocation3 == L'^' && *(TempLocation3+1) == L'|') {
- TempLocation3++;
- } else if (*TempLocation3 == L'|') {
- break;
- }
- }
- }
- if (TempLocation3 != NULL && *TempLocation3 != CHAR_NULL) {
+ if (ContainsSplit(PostVariableCmdLine)) {
//
// are we in an existing split???
//