public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/3] Revert "ShellPkg: Fix echo to support displaying special characters"
@ 2016-08-23  2:56 Ruiyu Ni
  2016-08-23  2:56 ` [PATCH 1/3] " Ruiyu Ni
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ruiyu Ni @ 2016-08-23  2:56 UTC (permalink / raw)
  To: edk2-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 1446 bytes --]

This reverts commit 95fc5a877502a6e6324300eed0136243d359fa96.
The above commit causes several regression of "echo" command:
1. Double quotes are not being stripped from the final text. UEFI Shell 2.2 section 3.4.5 chops out the quotes.
2. Output redirection is not working as expected. Text is being redirected, but the ‘> …’ text should not be.
3. Inconsistent special character handling.  For example, comments with # seem to be parsed out correctly, but handing of ^ is incorrect.
In summary, ‘echo “You are ^#1” > t.txt’ results in the below content in t.txt:
 “You are ^#1” > t.txt

Ruiyu Ni (3):
  Revert "ShellPkg: Fix echo to support displaying special characters"
  Revert "ShellPkg: Add Shell[Get|Set]RawCmdLine to ShellCommandLib"
  Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter to
    ShellCommandLib"

 ShellPkg/Application/Shell/Shell.c                 |  81 +++++---
 ShellPkg/Application/Shell/Shell.h                 |  18 ++
 .../Application/Shell/ShellParametersProtocol.c    | 160 +++++++++++++-
 .../Application/Shell/ShellParametersProtocol.h    |  29 +++
 ShellPkg/Include/Library/ShellCommandLib.h         |  68 ------
 .../UefiShellCommandLib/UefiShellCommandLib.c      | 230 ---------------------
 ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c | 141 +++++++------
 .../UefiShellLevel3CommandsLib.uni                 |   3 +-
 8 files changed, 339 insertions(+), 391 deletions(-)

-- 
2.9.0.windows.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] Revert "ShellPkg: Fix echo to support displaying special characters"
  2016-08-23  2:56 [PATCH 0/3] Revert "ShellPkg: Fix echo to support displaying special characters" Ruiyu Ni
@ 2016-08-23  2:56 ` Ruiyu Ni
  2016-08-23  2:56 ` [PATCH 2/3] Revert "ShellPkg: Add Shell[Get|Set]RawCmdLine to ShellCommandLib" Ruiyu Ni
  2016-08-23  2:56 ` [PATCH 3/3] Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter " Ruiyu Ni
  2 siblings, 0 replies; 6+ messages in thread
From: Ruiyu Ni @ 2016-08-23  2:56 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jaben Carsey

This reverts commit 95fc5a877502a6e6324300eed0136243d359fa96.
The above commit causes several regression of "echo" command:
1. Double quotes are not being stripped from the final text. UEFI Shell 2.2 section 3.4.5 chops out the quotes.
2. Output redirection is not working as expected. Text is being redirected, but the ‘> …’ text should not be.
3. Inconsistent special character handling.  For example, comments with # seem to be parsed out correctly, but handing of ^ is incorrect.
In summary, ‘echo “You are ^#1” > t.txt’ results in the below content in t.txt:
 “You are ^#1” > t.txt

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c | 141 ++++++++++++---------
 .../UefiShellLevel3CommandsLib.uni                 |   3 +-
 2 files changed, 81 insertions(+), 63 deletions(-)

diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c
index c98ee85..a638de8 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c
@@ -2,7 +2,7 @@
   Main file for Echo shell level 3 function.
 
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved. <BR>
+  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved. <BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
@@ -17,6 +17,12 @@
 
 #include <Library/ShellLib.h>
 
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
+  {L"-on", TypeFlag},
+  {L"-off", TypeFlag},
+  {NULL, TypeMax}
+  };
+
 /**
   Function for 'echo' command.
 
@@ -30,73 +36,86 @@ ShellCommandRunEcho (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
-  CHAR16              *RawCmdLine;
-  SHELL_STATUS        Status;
+  EFI_STATUS          Status;
+  LIST_ENTRY          *Package;
+  SHELL_STATUS        ShellStatus;
+  UINTN               ParamCount;
+  CHAR16              *ProblemParam;
   UINTN               Size;
-  CHAR16              *Walker;
-  CHAR16              *TempParameter;
-  BOOLEAN             OnFlag;
-  BOOLEAN             OffFlag;
-  UINTN               Count;
-
-  RawCmdLine = ShellGetRawCmdLine ();
-  if (RawCmdLine == NULL) {
-    return SHELL_OUT_OF_RESOURCES;
-  }
-
-  OnFlag  = FALSE;
-  OffFlag = FALSE;
-
-  Size = StrSize (RawCmdLine);
-  TempParameter  = AllocateZeroPool(Size);
-  if (TempParameter == NULL) {
-    Status = SHELL_OUT_OF_RESOURCES;
-    goto Done;
-  }
-
-  for ( Count = 0
-      , Walker = RawCmdLine
-      ; Walker != NULL && *Walker != CHAR_NULL
-      ; Count++
-      ) {
-    if (EFI_ERROR (ShellGetNextParameter (&Walker, TempParameter, Size, FALSE))) {
-      break;
+  CHAR16              *PrintString;
+
+  Size                = 0;
+  ProblemParam        = NULL;
+  PrintString         = NULL;
+  ShellStatus         = SHELL_SUCCESS;
+
+  //
+  // initialize the shell lib (we must be in non-auto-init...)
+  //
+  Status = ShellInitialize();
+  ASSERT_EFI_ERROR(Status);
+
+  //
+  // parse the command line
+  //
+  Status = ShellCommandLineParseEx (ParamList, &Package, &ProblemParam, TRUE, TRUE);
+  if (EFI_ERROR(Status)) {
+    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"echo", ProblemParam);  
+      FreePool(ProblemParam);
+      ShellStatus = SHELL_INVALID_PARAMETER;
+    } else {
+      ASSERT(FALSE);
     }
-
-    if (Count == 1) {
-      if (gUnicodeCollation->StriColl(gUnicodeCollation, TempParameter, L"-on") == 0 ) {
-        OnFlag = TRUE;
+  } else {
+    //
+    // check for "-?"
+    //
+    if (ShellCommandLineGetFlag(Package, L"-?")) {
+      ASSERT(FALSE);
+    }
+    if (ShellCommandLineGetFlag(Package, L"-on")) {
+      //
+      // Turn it on
+      //
+      ShellCommandSetEchoState(TRUE);
+    } else if (ShellCommandLineGetFlag(Package, L"-off")) {
+      //
+      // turn it off
+      //
+      ShellCommandSetEchoState(FALSE);
+    } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
+      //
+      // output its current state
+      //
+      if (ShellCommandGetEchoState()) {
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ECHO_ON), gShellLevel3HiiHandle);
+      } else {
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ECHO_OFF), gShellLevel3HiiHandle);
       }
-      if (gUnicodeCollation->StriColl(gUnicodeCollation, TempParameter, L"-off") == 0 ) {
-        OffFlag = TRUE;
+    } else {
+      //
+      // print the line
+      //
+      for ( ParamCount = 1
+          ; ShellCommandLineGetRawValue(Package, ParamCount) != NULL
+          ; ParamCount++
+         ) {
+        StrnCatGrow(&PrintString, &Size, ShellCommandLineGetRawValue(Package, ParamCount), 0);
+        if (ShellCommandLineGetRawValue(Package, ParamCount+1) != NULL) {
+          StrnCatGrow(&PrintString, &Size, L" ", 0);
+        } 
       }
-    }
-  }
-
-  if (OnFlag || OffFlag) {
-    if (Count != 2) {
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ECHO_INVALID_PARAM), gShellLevel3HiiHandle, L"echo", L"-on/-off");
-      Status = SHELL_INVALID_PARAMETER;
-      goto Done;
+      ShellPrintEx(-1, -1, L"%s\r\n", PrintString);
+      SHELL_FREE_NON_NULL(PrintString);
     }
 
-    ShellCommandSetEchoState(OnFlag);
-    Status = SHELL_SUCCESS;
-    goto Done;
+    //
+    // free the command line package
+    //
+    ShellCommandLineFreeVarList (Package);
   }
 
-  Walker = RawCmdLine + StrLen (L"echo");
-  if  (*Walker != CHAR_NULL) {
-    Walker++;
-    ShellPrintEx (-1, -1, L"%s\r\n", Walker);
-  }
-
-  Status = SHELL_SUCCESS;
-
-Done:
-  SHELL_FREE_NON_NULL (TempParameter);
-  SHELL_FREE_NON_NULL (RawCmdLine);
-  return Status;
-
+  return (ShellStatus);
 }
 
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni
index eeb870a..fc9c5d4 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni
@@ -1,7 +1,7 @@
 // /**
 //
 // (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
-// Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved. <BR>
+// Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved. <BR>
 // This program and the accompanying materials
 // are licensed and made available under the terms and conditions of the BSD License
 // which accompanies this distribution. The full text of the license may be found at
@@ -55,7 +55,6 @@
 
 #string STR_ECHO_ON               #language en-US "Echo is on.\r\n"
 #string STR_ECHO_OFF              #language en-US "Echo is off.\r\n"
-#string STR_ECHO_INVALID_PARAM    #language en-US "%H%s%N: Invalid  - too many parameters after '%s'\r\n"
 
 #string STR_PAUSE_PROMPT          #language en-US "Enter 'q' to quit, any other key to continue:\r\n"
 
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] Revert "ShellPkg: Add Shell[Get|Set]RawCmdLine to ShellCommandLib"
  2016-08-23  2:56 [PATCH 0/3] Revert "ShellPkg: Fix echo to support displaying special characters" Ruiyu Ni
  2016-08-23  2:56 ` [PATCH 1/3] " Ruiyu Ni
@ 2016-08-23  2:56 ` Ruiyu Ni
  2016-08-23  2:56 ` [PATCH 3/3] Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter " Ruiyu Ni
  2 siblings, 0 replies; 6+ messages in thread
From: Ruiyu Ni @ 2016-08-23  2:56 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jaben Carsey

This reverts commit 0fcf8d4df85d861b6e721bd1d8abb449f05e15ed.
The above commit causes several regression of "echo" command:
1. Double quotes are not being stripped from the final text. UEFI Shell 2.2 section 3.4.5 chops out the quotes.
2. Output redirection is not working as expected. Text is being redirected, but the ‘> …’ text should not be.
3. Inconsistent special character handling.  For example, comments with # seem to be parsed out correctly, but handing of ^ is incorrect.
In summary, ‘echo “You are ^#1” > t.txt’ results in the below content in t.txt:
 “You are ^#1” > t.txt

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 ShellPkg/Include/Library/ShellCommandLib.h         | 23 -----------
 .../UefiShellCommandLib/UefiShellCommandLib.c      | 45 ----------------------
 2 files changed, 68 deletions(-)

diff --git a/ShellPkg/Include/Library/ShellCommandLib.h b/ShellPkg/Include/Library/ShellCommandLib.h
index 44eccc4..5c5e241 100644
--- a/ShellPkg/Include/Library/ShellCommandLib.h
+++ b/ShellPkg/Include/Library/ShellCommandLib.h
@@ -670,29 +670,6 @@ ShellFileHandleEof(
   IN SHELL_FILE_HANDLE Handle
   );
 
-/**
-  Function to get the original CmdLine string for current command.
-
-  @return     A pointer to the buffer of the original command string.
-              It's the caller's responsibility to free the buffer.
-**/
-CHAR16*
-EFIAPI
-ShellGetRawCmdLine (
-  VOID
-  );
-
-/**
-  Function to store the orgignal command string into mOriginalCmdLine.
-
-  @param[in] CmdLine     the command line string to store.
-**/
-VOID
-EFIAPI
-ShellSetRawCmdLine (
-  IN CONST CHAR16     *CmdLine
-  );
-
 typedef struct {
   LIST_ENTRY    Link;
   void          *Buffer;
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index 7fe908c..ac77111 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -30,7 +30,6 @@ STATIC UINTN                              mProfileListSize;
 STATIC UINTN                              mFsMaxCount = 0;
 STATIC UINTN                              mBlkMaxCount = 0;
 STATIC BUFFER_LIST                        mFileHandleList;
-STATIC CHAR16                             *mRawCmdLine = NULL;
 
 STATIC CONST CHAR8 Hex[] = {
   '0',
@@ -1870,50 +1869,6 @@ ShellFileHandleEof(
 }
 
 /**
-  Function to get the original CmdLine string for current command.
-
-  @return     A pointer to the buffer of the original command string.
-              It's the caller's responsibility to free the buffer.
-**/
-CHAR16*
-EFIAPI
-ShellGetRawCmdLine (
-  VOID
-  )
-{
-  if (mRawCmdLine == NULL) {
-    return NULL;
-  } else {
-    return AllocateCopyPool(StrSize(mRawCmdLine), mRawCmdLine);
-  }
-}
-
-/**
-  Function to store the raw command string.
-
-  The alias and variables have been replaced and spaces are trimmed.
-
-  @param[in] CmdLine     the command line string to store.
-**/
-VOID
-EFIAPI
-ShellSetRawCmdLine (
-  IN CONST CHAR16     *CmdLine
-  )
-{
-  SHELL_FREE_NON_NULL(mRawCmdLine);
-
-  if (CmdLine != NULL) {
-    //
-    // The spaces in the beginning and end are trimmed.
-    //
-    ASSERT (*CmdLine != L' ');
-    ASSERT (CmdLine[StrLen (CmdLine) - 1] != L' ');
-    mRawCmdLine = AllocateCopyPool (StrSize(CmdLine), CmdLine);
-  }
-}
-
-/**
   Frees any BUFFER_LIST defined type.
 
   @param[in] List     The BUFFER_LIST object to free.
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter to ShellCommandLib"
  2016-08-23  2:56 [PATCH 0/3] Revert "ShellPkg: Fix echo to support displaying special characters" Ruiyu Ni
  2016-08-23  2:56 ` [PATCH 1/3] " Ruiyu Ni
  2016-08-23  2:56 ` [PATCH 2/3] Revert "ShellPkg: Add Shell[Get|Set]RawCmdLine to ShellCommandLib" Ruiyu Ni
@ 2016-08-23  2:56 ` Ruiyu Ni
  2016-08-23 13:45   ` Shah, Tapan
  2016-08-24 15:09   ` Shah, Tapan
  2 siblings, 2 replies; 6+ messages in thread
From: Ruiyu Ni @ 2016-08-23  2:56 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jaben Carsey

This reverts commit c0bcd3433f33876c519bf5567e0ab69261b57fe9.
The above commit causes several regression of "echo" command:
1. Double quotes are not being stripped from the final text. UEFI Shell 2.2 section 3.4.5 chops out the quotes.
2. Output redirection is not working as expected. Text is being redirected, but the ‘> …’ text should not be.
3. Inconsistent special character handling.  For example, comments with # seem to be parsed out correctly, but handing of ^ is incorrect.
In summary, ‘echo “You are ^#1” > t.txt’ results in the below content in t.txt:
 “You are ^#1” > t.txt

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 ShellPkg/Application/Shell/Shell.c                 |  81 +++++----
 ShellPkg/Application/Shell/Shell.h                 |  18 ++
 .../Application/Shell/ShellParametersProtocol.c    | 160 +++++++++++++++++-
 .../Application/Shell/ShellParametersProtocol.h    |  29 ++++
 ShellPkg/Include/Library/ShellCommandLib.h         |  45 -----
 .../UefiShellCommandLib/UefiShellCommandLib.c      | 185 ---------------------
 6 files changed, 258 insertions(+), 260 deletions(-)

diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c
index 3080a16..0b6362e 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -213,7 +213,7 @@ ContainsSplit(
 
   FirstQuote    = FindNextInstance (CmdLine, L"\"", TRUE);
   SecondQuote   = NULL;
-  TempSpot      = ShellFindFirstCharacter(CmdLine, L"|", TRUE);
+  TempSpot      = FindFirstCharacter(CmdLine, L"|", L'^');
 
   if (FirstQuote == NULL    || 
       TempSpot == NULL      || 
@@ -236,7 +236,7 @@ ContainsSplit(
       continue;
     } else {
       FirstQuote = FindNextInstance (SecondQuote + 1, L"\"", TRUE);
-      TempSpot = ShellFindFirstCharacter(TempSpot + 1, L"|", TRUE);
+      TempSpot = FindFirstCharacter(TempSpot + 1, L"|", L'^');
       continue;
     } 
   }
@@ -716,7 +716,6 @@ FreeResources:
   }
 
   ShellFreeEnvVarList ();
-  ShellSetRawCmdLine (NULL);
 
   if (ShellCommandGetExit()) {
     return ((EFI_STATUS)ShellCommandGetExitCode());
@@ -1993,7 +1992,7 @@ IsValidSplit(
       return (EFI_OUT_OF_RESOURCES);
     }
     TempWalker = (CHAR16*)Temp;
-    if (!EFI_ERROR (ShellGetNextParameter (&TempWalker, FirstParameter, StrSize(CmdLine), TRUE))) {
+    if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, StrSize(CmdLine), TRUE))) {
       if (GetOperationType(FirstParameter) == Unknown_Invalid) {
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
         SetLastError(SHELL_NOT_FOUND);
@@ -2042,7 +2041,7 @@ VerifySplit(
   //
   // recurse to verify the next item
   //
-  TempSpot = ShellFindFirstCharacter(CmdLine, L"|", TRUE) + 1;
+  TempSpot = FindFirstCharacter(CmdLine, L"|", L'^') + 1;
   if (*TempSpot == L'a' && 
       (*(TempSpot + 1) == L' ' || *(TempSpot + 1) == CHAR_NULL)
      ) {
@@ -2159,7 +2158,7 @@ DoHelpUpdate(
 
   Walker = *CmdLine;
   while(Walker != NULL && *Walker != CHAR_NULL) {
-    if (!EFI_ERROR (ShellGetNextParameter (&Walker, CurrentParameter, StrSize(*CmdLine), TRUE))) {
+    if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter, StrSize(*CmdLine), TRUE))) {
       if (StrStr(CurrentParameter, L"-?") == CurrentParameter) {
         CurrentParameter[0] = L' ';
         CurrentParameter[1] = L' ';
@@ -2590,7 +2589,6 @@ RunShellCommand(
   CHAR16                    *FirstParameter;
   CHAR16                    *TempWalker;
   SHELL_OPERATION_TYPES     Type;
-  CHAR16                    *OldCmdLine;
 
   ASSERT(CmdLine != NULL);
   if (StrLen(CmdLine) == 0) {
@@ -2598,14 +2596,11 @@ RunShellCommand(
   }
 
   Status              = EFI_SUCCESS;
-  FirstParameter      = NULL;
   CleanOriginal       = NULL;
-  OldCmdLine          = NULL;
 
   CleanOriginal = StrnCatGrow(&CleanOriginal, NULL, CmdLine, 0);
   if (CleanOriginal == NULL) {
-    Status = EFI_OUT_OF_RESOURCES;
-    goto Done;
+    return (EFI_OUT_OF_RESOURCES);
   }
 
   TrimSpaces(&CleanOriginal);
@@ -2632,36 +2627,35 @@ RunShellCommand(
   // Handle case that passed in command line is just 1 or more " " characters.
   //
   if (StrLen (CleanOriginal) == 0) {
-    Status = EFI_SUCCESS;
-    goto Done;
+    SHELL_FREE_NON_NULL(CleanOriginal);
+    return (EFI_SUCCESS);
   }
 
   Status = ProcessCommandLineToFinal(&CleanOriginal);
   if (EFI_ERROR(Status)) {
-    goto Done;
+    SHELL_FREE_NON_NULL(CleanOriginal);
+    return (Status);
   }
 
-  OldCmdLine = ShellGetRawCmdLine ();
-  ShellSetRawCmdLine (CleanOriginal);
-
   //
   // We don't do normal processing with a split command line (output from one command input to another)
   //
   if (ContainsSplit(CleanOriginal)) {
     Status = ProcessNewSplitCommandLine(CleanOriginal);
-    goto Done;
-  }
+    SHELL_FREE_NON_NULL(CleanOriginal);
+    return (Status);
+  } 
 
   //
   // We need the first parameter information so we can determine the operation type
   //
   FirstParameter = AllocateZeroPool(StrSize(CleanOriginal));
   if (FirstParameter == NULL) {
-    Status = EFI_OUT_OF_RESOURCES;
-    goto Done;
+    SHELL_FREE_NON_NULL(CleanOriginal);
+    return (EFI_OUT_OF_RESOURCES);
   }
   TempWalker = CleanOriginal;
-  if (!EFI_ERROR (ShellGetNextParameter (&TempWalker, FirstParameter, StrSize(CleanOriginal), TRUE))) {
+  if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, StrSize(CleanOriginal), TRUE))) {
     //
     // Depending on the first parameter we change the behavior
     //
@@ -2686,12 +2680,9 @@ RunShellCommand(
     ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
     SetLastError(SHELL_NOT_FOUND);
   }
-
-Done:
-  ShellSetRawCmdLine (OldCmdLine);
-  SHELL_FREE_NON_NULL (OldCmdLine);
-  SHELL_FREE_NON_NULL (CleanOriginal);
-  SHELL_FREE_NON_NULL (FirstParameter);
+ 
+  SHELL_FREE_NON_NULL(CleanOriginal);
+  SHELL_FREE_NON_NULL(FirstParameter);
 
   return (Status);
 }
@@ -3129,3 +3120,37 @@ RunScriptFile (
   return (Status);
 }
 
+/**
+  Return the pointer to the first occurrence of any character from a list of characters.
+
+  @param[in] String           the string to parse
+  @param[in] CharacterList    the list of character to look for
+  @param[in] EscapeCharacter  An escape character to skip
+
+  @return the location of the first character in the string
+  @retval CHAR_NULL no instance of any character in CharacterList was found in String
+**/
+CONST CHAR16*
+EFIAPI
+FindFirstCharacter(
+  IN CONST CHAR16 *String,
+  IN CONST CHAR16 *CharacterList,
+  IN CONST CHAR16 EscapeCharacter
+  )
+{
+  UINT32 WalkChar;
+  UINT32 WalkStr;
+
+  for (WalkStr = 0; WalkStr < StrLen(String); WalkStr++) {
+    if (String[WalkStr] == EscapeCharacter) {
+      WalkStr++;
+      continue;
+    }
+    for (WalkChar = 0; WalkChar < StrLen(CharacterList); WalkChar++) {
+      if (String[WalkStr] == CharacterList[WalkChar]) {
+        return (&String[WalkStr]);
+      }
+    }
+  }
+  return (String + StrLen(String));
+}
diff --git a/ShellPkg/Application/Shell/Shell.h b/ShellPkg/Application/Shell/Shell.h
index a34c91a..29b36b0 100644
--- a/ShellPkg/Application/Shell/Shell.h
+++ b/ShellPkg/Application/Shell/Shell.h
@@ -371,6 +371,24 @@ RunScriptFile (
   );
 
 /**
+  Return the pointer to the first occurrence of any character from a list of characters.
+
+  @param[in] String           the string to parse
+  @param[in] CharacterList    the list of character to look for
+  @param[in] EscapeCharacter  An escape character to skip
+
+  @return the location of the first character in the string
+  @retval CHAR_NULL no instance of any character in CharacterList was found in String
+**/
+CONST CHAR16*
+EFIAPI
+FindFirstCharacter(
+  IN CONST CHAR16 *String,
+  IN CONST CHAR16 *CharacterList,
+  IN CONST CHAR16 EscapeCharacter
+  );
+
+/**
   Cleans off leading and trailing spaces and tabs.
 
   @param[in] String pointer to the string to trim them off.
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c
index 0785902..3684f9c 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
@@ -20,6 +20,162 @@
 BOOLEAN AsciiRedirection = FALSE;
 
 /**
+  Return the next parameter's end from a command line string.
+
+  @param[in] String        the string to parse
+**/
+CONST CHAR16*
+EFIAPI
+FindEndOfParameter(
+  IN CONST CHAR16 *String
+  )
+{
+  CONST CHAR16 *First;
+  CONST CHAR16 *CloseQuote;
+
+  First = FindFirstCharacter(String, L" \"", L'^');
+
+  //
+  // nothing, all one parameter remaining
+  //
+  if (*First == CHAR_NULL) {
+    return (First);
+  }
+
+  //
+  // If space before a quote (or neither found, i.e. both CHAR_NULL),
+  // then that's the end.
+  //
+  if (*First == L' ') {
+    return (First);
+  }
+
+  CloseQuote = FindFirstCharacter (First+1, L"\"", L'^');
+
+  //
+  // We did not find a terminator...
+  //
+  if (*CloseQuote == CHAR_NULL) {
+    return (NULL);
+  }
+
+  return (FindEndOfParameter (CloseQuote+1));
+}
+
+/**
+  Return the next parameter from a command line string.
+
+  This function moves the next parameter from Walker into TempParameter and moves
+  Walker up past that parameter for recursive calling.  When the final parameter
+  is moved *Walker will be set to NULL;
+
+  Temp Parameter must be large enough to hold the parameter before calling this
+  function.
+
+  This will also remove all remaining ^ characters after processing.
+
+  @param[in, out] Walker          pointer to string of command line.  Adjusted to
+                                  reminaing command line on return
+  @param[in, out] TempParameter   pointer to string of command line item extracted.
+  @param[in]      Length          buffer size of TempParameter.
+  @param[in]      StripQuotation  if TRUE then strip the quotation marks surrounding
+                                  the parameters.
+
+  @return   EFI_INALID_PARAMETER  A required parameter was NULL or pointed to a NULL or empty string.
+  @return   EFI_NOT_FOUND         A closing " could not be found on the specified string
+**/
+EFI_STATUS
+EFIAPI
+GetNextParameter(
+  IN OUT CHAR16   **Walker,
+  IN OUT CHAR16   **TempParameter,
+  IN CONST UINTN  Length,
+  IN BOOLEAN      StripQuotation
+  )
+{
+  CONST CHAR16 *NextDelim;
+
+  if (Walker           == NULL
+    ||*Walker          == NULL
+    ||TempParameter    == NULL
+    ||*TempParameter   == NULL
+    ){
+    return (EFI_INVALID_PARAMETER);
+  }
+
+
+  //
+  // make sure we dont have any leading spaces
+  //
+  while ((*Walker)[0] == L' ') {
+      (*Walker)++;
+  }
+
+  //
+  // make sure we still have some params now...
+  //
+  if (StrLen(*Walker) == 0) {
+DEBUG_CODE_BEGIN();
+    *Walker        = NULL;
+DEBUG_CODE_END();
+    return (EFI_INVALID_PARAMETER);
+  }
+
+  NextDelim = FindEndOfParameter(*Walker);
+
+  if (NextDelim == NULL){
+DEBUG_CODE_BEGIN();
+    *Walker        = NULL;
+DEBUG_CODE_END();
+    return (EFI_NOT_FOUND);
+  }
+
+  StrnCpyS(*TempParameter, Length / sizeof(CHAR16), (*Walker), NextDelim - *Walker);
+
+  //
+  // Add a CHAR_NULL if we didnt get one via the copy
+  //
+  if (*NextDelim != CHAR_NULL) {
+    (*TempParameter)[NextDelim - *Walker] = CHAR_NULL;
+  }
+
+  //
+  // Update Walker for the next iteration through the function
+  //
+  *Walker = (CHAR16*)NextDelim;
+
+  //
+  // Remove any non-escaped quotes in the string
+  // Remove any remaining escape characters in the string
+  //
+  for (NextDelim = FindFirstCharacter(*TempParameter, L"\"^", CHAR_NULL) 
+    ; *NextDelim != CHAR_NULL 
+    ; NextDelim = FindFirstCharacter(NextDelim, L"\"^", CHAR_NULL)
+    ) {
+    if (*NextDelim == L'^') {
+
+      //
+      // eliminate the escape ^
+      //
+      CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
+      NextDelim++;
+    } else if (*NextDelim == L'\"') {
+
+      //
+      // eliminate the unescaped quote
+      //
+      if (StripQuotation) {
+        CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
+	  } else{
+        NextDelim++;
+	  }
+    }
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
   Function to populate Argc and Argv.
 
   This function parses the CommandLine and divides it into standard C style Argc/Argv
@@ -82,7 +238,7 @@ ParseCommandLineToArgs(
       ; Walker != NULL && *Walker != CHAR_NULL
       ; Count++
       ) {
-    if (EFI_ERROR (ShellGetNextParameter (&Walker, TempParameter, Size, TRUE))) {
+    if (EFI_ERROR(GetNextParameter(&Walker, &TempParameter, Size, TRUE))) {
       break;
     }
   }
@@ -100,7 +256,7 @@ ParseCommandLineToArgs(
   Walker = (CHAR16*)NewCommandLine;
   while(Walker != NULL && *Walker != CHAR_NULL) {
     SetMem16(TempParameter, Size, CHAR_NULL);
-    if (EFI_ERROR (ShellGetNextParameter (&Walker, TempParameter, Size, StripQuotation))) {
+    if (EFI_ERROR(GetNextParameter(&Walker, &TempParameter, Size, StripQuotation))) {
       Status = EFI_INVALID_PARAMETER;
       goto Done;
     }
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.h b/ShellPkg/Application/Shell/ShellParametersProtocol.h
index 1205d92..926f362 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.h
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.h
@@ -190,5 +190,34 @@ ParseCommandLineToArgs(
   IN OUT UINTN    *Argc
   );
 
+/**
+  return the next parameter from a command line string;
+
+  This function moves the next parameter from Walker into TempParameter and moves
+  Walker up past that parameter for recursive calling.  When the final parameter
+  is moved *Walker will be set to NULL;
+
+  Temp Parameter must be large enough to hold the parameter before calling this
+  function.
+
+  @param[in, out] Walker          pointer to string of command line.  Adjusted to
+                                  reminaing command line on return
+  @param[in, out] TempParameter   pointer to string of command line item extracted.
+  @param[in]      Length          Length of (*TempParameter) in bytes
+  @param[in]      StripQuotation  if TRUE then strip the quotation marks surrounding
+                                  the parameters.
+
+  @return   EFI_INALID_PARAMETER  A required parameter was NULL or pointed to a NULL or empty string.
+  @return   EFI_NOT_FOUND         A closing " could not be found on the specified string
+**/
+EFI_STATUS
+EFIAPI
+GetNextParameter(
+  IN OUT CHAR16   **Walker,
+  IN OUT CHAR16   **TempParameter,
+  IN CONST UINTN  Length,
+  IN BOOLEAN      StripQuotation
+  );
+
 #endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_
 
diff --git a/ShellPkg/Include/Library/ShellCommandLib.h b/ShellPkg/Include/Library/ShellCommandLib.h
index 5c5e241..3ee8200 100644
--- a/ShellPkg/Include/Library/ShellCommandLib.h
+++ b/ShellPkg/Include/Library/ShellCommandLib.h
@@ -719,49 +719,4 @@ CatSDumpHex (
   IN UINTN   DataSize,
   IN VOID    *UserData
   );
-
-/**
-  Return the pointer to the first occurrence of any character from a list of characters.
-
-  @param[in] String                 The string to parse
-  @param[in] CharacterList          The list of character to look for
-  @param[in] IgnoreEscapedCharacter TRUE to ignore escaped characters
-
-  @return The location of the first character in the String.
-  @return Pointer to the ending NULL character of the String.
-**/
-CONST CHAR16*
-EFIAPI
-ShellFindFirstCharacter (
-  IN CONST CHAR16  *String,
-  IN CONST CHAR16  *CharacterList,
-  IN CONST BOOLEAN IgnoreEscapedCharacter
-  );
-
-/**
-  return the next parameter from a command line string;
-
-  This function moves the next parameter from Walker into NextParameter and moves
-  Walker up past that parameter for recursive calling.  When the final parameter
-  is moved *Walker will be set to NULL;
-
-  @param[in, out] Walker          pointer to string of command line.  Adjusted to
-                                  reminaing command line on return
-  @param[in, out] NextParameter   string of command line item extracted.
-  @param[in]      Length          Length of TempParameter in bytes
-  @param[in]      StripQuotation  if TRUE then strip the quotation marks surrounding
-                                  the parameters.
-
-  @return   EFI_INALID_PARAMETER  A required parameter was NULL or pointed to a NULL or empty string.
-  @return   EFI_NOT_FOUND         A closing " could not be found on the specified string
-**/
-EFI_STATUS
-EFIAPI
-ShellGetNextParameter(
-  IN OUT CHAR16   **Walker,
-  IN OUT CHAR16   *NextParameter,
-  IN CONST UINTN  Length,
-  IN BOOLEAN      StripQuotation
-  );
-
 #endif //_SHELL_COMMAND_LIB_
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index ac77111..a97361c 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -83,191 +83,6 @@ CommandInit(
 }
 
 /**
-  Return the pointer to the first occurrence of any character from a list of characters.
-
-  @param[in] String                 The string to parse
-  @param[in] CharacterList          The list of character to look for
-  @param[in] IgnoreEscapedCharacter TRUE to ignore escaped characters
-
-  @return The location of the first character in the String.
-  @return Pointer to the ending NULL character of the String.
-**/
-CONST CHAR16*
-EFIAPI
-ShellFindFirstCharacter (
-  IN CONST CHAR16  *String,
-  IN CONST CHAR16  *CharacterList,
-  IN CONST BOOLEAN IgnoreEscapedCharacter
-  )
-{
-  UINTN WalkChar;
-  UINTN WalkStr;
-
-  for (WalkStr = 0; WalkStr < StrLen (String); WalkStr++) {
-    if (IgnoreEscapedCharacter && (String[WalkStr] == L'^')) {
-      WalkStr++;
-      continue;
-    }
-    for (WalkChar = 0; WalkChar < StrLen (CharacterList); WalkChar++) {
-      if (String[WalkStr] == CharacterList[WalkChar]) {
-        return &String[WalkStr];
-      }
-    }
-  }
-  return &String[WalkStr];
-}
-
-/**
-  Return the next parameter's end from a command line string.
-
-  @param[in] String        the string to parse
-**/
-CONST CHAR16*
-FindEndOfParameter(
-  IN CONST CHAR16 *String
-  )
-{
-  CONST CHAR16 *First;
-  CONST CHAR16 *CloseQuote;
-
-  First = ShellFindFirstCharacter (String, L" \"", TRUE);
-
-  //
-  // nothing, all one parameter remaining
-  //
-  if (*First == CHAR_NULL) {
-    return (First);
-  }
-
-  //
-  // If space before a quote (or neither found, i.e. both CHAR_NULL),
-  // then that's the end.
-  //
-  if (*First == L' ') {
-    return (First);
-  }
-
-  CloseQuote = ShellFindFirstCharacter (First+1, L"\"", TRUE);
-
-  //
-  // We did not find a terminator...
-  //
-  if (*CloseQuote == CHAR_NULL) {
-    return (NULL);
-  }
-
-  return (FindEndOfParameter (CloseQuote+1));
-}
-
-/**
-  Return the next parameter from a command line string.
-
-  This function moves the next parameter from Walker into NextParameter and moves
-  Walker up past that parameter for recursive calling.  When the final parameter
-  is moved *Walker will be set to NULL;
-
-  This will also remove all remaining ^ characters after processing.
-
-  @param[in, out] Walker          pointer to string of command line.  Adjusted to
-                                  reminaing command line on return
-  @param[in, out] NextParameter   pointer to string of command line item extracted.
-  @param[in]      Length          buffer size of TempParameter.
-  @param[in]      StripQuotation  if TRUE then strip the quotation marks surrounding
-                                  the parameters.
-
-  @return   EFI_INALID_PARAMETER  A required parameter was NULL or pointed to a NULL or empty string.
-  @return   EFI_NOT_FOUND         A closing " could not be found on the specified string
-**/
-EFI_STATUS
-EFIAPI
-ShellGetNextParameter (
-  IN OUT CHAR16   **Walker,
-  IN OUT CHAR16   *NextParameter,
-  IN CONST UINTN  Length,
-  IN BOOLEAN      StripQuotation
-  )
-{
-  CONST CHAR16 *NextDelim;
-
-  if (Walker           == NULL
-    ||*Walker          == NULL
-    ||NextParameter    == NULL
-    ){
-    return EFI_INVALID_PARAMETER;
-  }
-
-  //
-  // make sure we dont have any leading spaces
-  //
-  while ((*Walker)[0] == L' ') {
-    (*Walker)++;
-  }
-
-  //
-  // make sure we still have some params now...
-  //
-  if (StrLen(*Walker) == 0) {
-    DEBUG_CODE (
-      *Walker = NULL;
-    );
-    return (EFI_INVALID_PARAMETER);
-  }
-
-  NextDelim = FindEndOfParameter(*Walker);
-
-  if (NextDelim == NULL){
-    DEBUG_CODE (
-      *Walker = NULL;
-    );
-    return (EFI_NOT_FOUND);
-  }
-
-  StrnCpyS(NextParameter, Length / sizeof(CHAR16), (*Walker), NextDelim - *Walker);
-
-  //
-  // Add a CHAR_NULL if we didnt get one via the copy
-  //
-  if (*NextDelim != CHAR_NULL) {
-    NextParameter[NextDelim - *Walker] = CHAR_NULL;
-  }
-
-  //
-  // Update Walker for the next iteration through the function
-  //
-  *Walker = (CHAR16*)NextDelim;
-
-  //
-  // Remove any non-escaped quotes in the string
-  // Remove any remaining escape characters in the string
-  //
-  for (NextDelim = ShellFindFirstCharacter(NextParameter, L"\"^", FALSE)
-    ; *NextDelim != CHAR_NULL
-    ; NextDelim = ShellFindFirstCharacter(NextDelim, L"\"^", FALSE)
-    ) {
-    if (*NextDelim == L'^') {
-
-      //
-      // eliminate the escape ^
-      //
-      CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
-      NextDelim++;
-    } else if (*NextDelim == L'\"') {
-
-      //
-      // eliminate the unescaped quote
-      //
-      if (StripQuotation) {
-        CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
-      } else {
-        NextDelim++;
-      }
-    }
-  }
-
-  return EFI_SUCCESS;
-}
-
-/**
   Constructor for the Shell Command library.
 
   Initialize the library and determine if the underlying is a UEFI Shell 2.0 or an EFI shell.
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter to ShellCommandLib"
  2016-08-23  2:56 ` [PATCH 3/3] Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter " Ruiyu Ni
@ 2016-08-23 13:45   ` Shah, Tapan
  2016-08-24 15:09   ` Shah, Tapan
  1 sibling, 0 replies; 6+ messages in thread
From: Shah, Tapan @ 2016-08-23 13:45 UTC (permalink / raw)
  To: Ruiyu Ni, edk2-devel@lists.01.org; +Cc: Jaben Carsey

Series Reviewed By: Tapan Shah <tapandshah@hpe.com>

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Monday, August 22, 2016 9:56 PM
To: edk2-devel@lists.01.org
Cc: Jaben Carsey <jaben.carsey@intel.com>
Subject: [edk2] [PATCH 3/3] Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter to ShellCommandLib"

This reverts commit c0bcd3433f33876c519bf5567e0ab69261b57fe9.
The above commit causes several regression of "echo" command:
1. Double quotes are not being stripped from the final text. UEFI Shell 2.2 section 3.4.5 chops out the quotes.
2. Output redirection is not working as expected. Text is being redirected, but the ‘> …’ text should not be.
3. Inconsistent special character handling.  For example, comments with # seem to be parsed out correctly, but handing of ^ is incorrect.
In summary, ‘echo “You are ^#1” > t.txt’ results in the below content in t.txt:
 “You are ^#1” > t.txt

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 ShellPkg/Application/Shell/Shell.c                 |  81 +++++----
 ShellPkg/Application/Shell/Shell.h                 |  18 ++
 .../Application/Shell/ShellParametersProtocol.c    | 160 +++++++++++++++++-
 .../Application/Shell/ShellParametersProtocol.h    |  29 ++++
 ShellPkg/Include/Library/ShellCommandLib.h         |  45 -----
 .../UefiShellCommandLib/UefiShellCommandLib.c      | 185 ---------------------
 6 files changed, 258 insertions(+), 260 deletions(-)

diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c
index 3080a16..0b6362e 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -213,7 +213,7 @@ ContainsSplit(
 
   FirstQuote    = FindNextInstance (CmdLine, L"\"", TRUE);
   SecondQuote   = NULL;
-  TempSpot      = ShellFindFirstCharacter(CmdLine, L"|", TRUE);
+  TempSpot      = FindFirstCharacter(CmdLine, L"|", L'^');
 
   if (FirstQuote == NULL    || 
       TempSpot == NULL      || 
@@ -236,7 +236,7 @@ ContainsSplit(
       continue;
     } else {
       FirstQuote = FindNextInstance (SecondQuote + 1, L"\"", TRUE);
-      TempSpot = ShellFindFirstCharacter(TempSpot + 1, L"|", TRUE);
+      TempSpot = FindFirstCharacter(TempSpot + 1, L"|", L'^');
       continue;
     } 
   }
@@ -716,7 +716,6 @@ FreeResources:
   }
 
   ShellFreeEnvVarList ();
-  ShellSetRawCmdLine (NULL);
 
   if (ShellCommandGetExit()) {
     return ((EFI_STATUS)ShellCommandGetExitCode());
@@ -1993,7 +1992,7 @@ IsValidSplit(
       return (EFI_OUT_OF_RESOURCES);
     }
     TempWalker = (CHAR16*)Temp;
-    if (!EFI_ERROR (ShellGetNextParameter (&TempWalker, FirstParameter, StrSize(CmdLine), TRUE))) {
+    if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, 
+ StrSize(CmdLine), TRUE))) {
       if (GetOperationType(FirstParameter) == Unknown_Invalid) {
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
         SetLastError(SHELL_NOT_FOUND);
@@ -2042,7 +2041,7 @@ VerifySplit(
   //
   // recurse to verify the next item
   //
-  TempSpot = ShellFindFirstCharacter(CmdLine, L"|", TRUE) + 1;
+  TempSpot = FindFirstCharacter(CmdLine, L"|", L'^') + 1;
   if (*TempSpot == L'a' && 
       (*(TempSpot + 1) == L' ' || *(TempSpot + 1) == CHAR_NULL)
      ) {
@@ -2159,7 +2158,7 @@ DoHelpUpdate(
 
   Walker = *CmdLine;
   while(Walker != NULL && *Walker != CHAR_NULL) {
-    if (!EFI_ERROR (ShellGetNextParameter (&Walker, CurrentParameter, StrSize(*CmdLine), TRUE))) {
+    if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter, 
+ StrSize(*CmdLine), TRUE))) {
       if (StrStr(CurrentParameter, L"-?") == CurrentParameter) {
         CurrentParameter[0] = L' ';
         CurrentParameter[1] = L' ';
@@ -2590,7 +2589,6 @@ RunShellCommand(
   CHAR16                    *FirstParameter;
   CHAR16                    *TempWalker;
   SHELL_OPERATION_TYPES     Type;
-  CHAR16                    *OldCmdLine;
 
   ASSERT(CmdLine != NULL);
   if (StrLen(CmdLine) == 0) {
@@ -2598,14 +2596,11 @@ RunShellCommand(
   }
 
   Status              = EFI_SUCCESS;
-  FirstParameter      = NULL;
   CleanOriginal       = NULL;
-  OldCmdLine          = NULL;
 
   CleanOriginal = StrnCatGrow(&CleanOriginal, NULL, CmdLine, 0);
   if (CleanOriginal == NULL) {
-    Status = EFI_OUT_OF_RESOURCES;
-    goto Done;
+    return (EFI_OUT_OF_RESOURCES);
   }
 
   TrimSpaces(&CleanOriginal);
@@ -2632,36 +2627,35 @@ RunShellCommand(
   // Handle case that passed in command line is just 1 or more " " characters.
   //
   if (StrLen (CleanOriginal) == 0) {
-    Status = EFI_SUCCESS;
-    goto Done;
+    SHELL_FREE_NON_NULL(CleanOriginal);
+    return (EFI_SUCCESS);
   }
 
   Status = ProcessCommandLineToFinal(&CleanOriginal);
   if (EFI_ERROR(Status)) {
-    goto Done;
+    SHELL_FREE_NON_NULL(CleanOriginal);
+    return (Status);
   }
 
-  OldCmdLine = ShellGetRawCmdLine ();
-  ShellSetRawCmdLine (CleanOriginal);
-
   //
   // We don't do normal processing with a split command line (output from one command input to another)
   //
   if (ContainsSplit(CleanOriginal)) {
     Status = ProcessNewSplitCommandLine(CleanOriginal);
-    goto Done;
-  }
+    SHELL_FREE_NON_NULL(CleanOriginal);
+    return (Status);
+  }
 
   //
   // We need the first parameter information so we can determine the operation type
   //
   FirstParameter = AllocateZeroPool(StrSize(CleanOriginal));
   if (FirstParameter == NULL) {
-    Status = EFI_OUT_OF_RESOURCES;
-    goto Done;
+    SHELL_FREE_NON_NULL(CleanOriginal);
+    return (EFI_OUT_OF_RESOURCES);
   }
   TempWalker = CleanOriginal;
-  if (!EFI_ERROR (ShellGetNextParameter (&TempWalker, FirstParameter, StrSize(CleanOriginal), TRUE))) {
+  if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, 
+ StrSize(CleanOriginal), TRUE))) {
     //
     // Depending on the first parameter we change the behavior
     //
@@ -2686,12 +2680,9 @@ RunShellCommand(
     ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
     SetLastError(SHELL_NOT_FOUND);
   }
-
-Done:
-  ShellSetRawCmdLine (OldCmdLine);
-  SHELL_FREE_NON_NULL (OldCmdLine);
-  SHELL_FREE_NON_NULL (CleanOriginal);
-  SHELL_FREE_NON_NULL (FirstParameter);
+ 
+  SHELL_FREE_NON_NULL(CleanOriginal);
+  SHELL_FREE_NON_NULL(FirstParameter);
 
   return (Status);
 }
@@ -3129,3 +3120,37 @@ RunScriptFile (
   return (Status);
 }
 
+/**
+  Return the pointer to the first occurrence of any character from a list of characters.
+
+  @param[in] String           the string to parse
+  @param[in] CharacterList    the list of character to look for
+  @param[in] EscapeCharacter  An escape character to skip
+
+  @return the location of the first character in the string
+  @retval CHAR_NULL no instance of any character in CharacterList was 
+found in String **/ CONST CHAR16* EFIAPI FindFirstCharacter(
+  IN CONST CHAR16 *String,
+  IN CONST CHAR16 *CharacterList,
+  IN CONST CHAR16 EscapeCharacter
+  )
+{
+  UINT32 WalkChar;
+  UINT32 WalkStr;
+
+  for (WalkStr = 0; WalkStr < StrLen(String); WalkStr++) {
+    if (String[WalkStr] == EscapeCharacter) {
+      WalkStr++;
+      continue;
+    }
+    for (WalkChar = 0; WalkChar < StrLen(CharacterList); WalkChar++) {
+      if (String[WalkStr] == CharacterList[WalkChar]) {
+        return (&String[WalkStr]);
+      }
+    }
+  }
+  return (String + StrLen(String));
+}
diff --git a/ShellPkg/Application/Shell/Shell.h b/ShellPkg/Application/Shell/Shell.h
index a34c91a..29b36b0 100644
--- a/ShellPkg/Application/Shell/Shell.h
+++ b/ShellPkg/Application/Shell/Shell.h
@@ -371,6 +371,24 @@ RunScriptFile (
   );
 
 /**
+  Return the pointer to the first occurrence of any character from a list of characters.
+
+  @param[in] String           the string to parse
+  @param[in] CharacterList    the list of character to look for
+  @param[in] EscapeCharacter  An escape character to skip
+
+  @return the location of the first character in the string
+  @retval CHAR_NULL no instance of any character in CharacterList was 
+found in String **/ CONST CHAR16* EFIAPI FindFirstCharacter(
+  IN CONST CHAR16 *String,
+  IN CONST CHAR16 *CharacterList,
+  IN CONST CHAR16 EscapeCharacter
+  );
+
+/**
   Cleans off leading and trailing spaces and tabs.
 
   @param[in] String pointer to the string to trim them off.
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c
index 0785902..3684f9c 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
@@ -20,6 +20,162 @@
 BOOLEAN AsciiRedirection = FALSE;
 
 /**
+  Return the next parameter's end from a command line string.
+
+  @param[in] String        the string to parse
+**/
+CONST CHAR16*
+EFIAPI
+FindEndOfParameter(
+  IN CONST CHAR16 *String
+  )
+{
+  CONST CHAR16 *First;
+  CONST CHAR16 *CloseQuote;
+
+  First = FindFirstCharacter(String, L" \"", L'^');
+
+  //
+  // nothing, all one parameter remaining  //  if (*First == CHAR_NULL) 
+ {
+    return (First);
+  }
+
+  //
+  // If space before a quote (or neither found, i.e. both CHAR_NULL),  
+ // then that's the end.
+  //
+  if (*First == L' ') {
+    return (First);
+  }
+
+  CloseQuote = FindFirstCharacter (First+1, L"\"", L'^');
+
+  //
+  // We did not find a terminator...
+  //
+  if (*CloseQuote == CHAR_NULL) {
+    return (NULL);
+  }
+
+  return (FindEndOfParameter (CloseQuote+1)); }
+
+/**
+  Return the next parameter from a command line string.
+
+  This function moves the next parameter from Walker into TempParameter 
+ and moves  Walker up past that parameter for recursive calling.  When 
+ the final parameter  is moved *Walker will be set to NULL;
+
+  Temp Parameter must be large enough to hold the parameter before 
+ calling this  function.
+
+  This will also remove all remaining ^ characters after processing.
+
+  @param[in, out] Walker          pointer to string of command line.  Adjusted to
+                                  reminaing command line on return
+  @param[in, out] TempParameter   pointer to string of command line item extracted.
+  @param[in]      Length          buffer size of TempParameter.
+  @param[in]      StripQuotation  if TRUE then strip the quotation marks surrounding
+                                  the parameters.
+
+  @return   EFI_INALID_PARAMETER  A required parameter was NULL or pointed to a NULL or empty string.
+  @return   EFI_NOT_FOUND         A closing " could not be found on the specified string
+**/
+EFI_STATUS
+EFIAPI
+GetNextParameter(
+  IN OUT CHAR16   **Walker,
+  IN OUT CHAR16   **TempParameter,
+  IN CONST UINTN  Length,
+  IN BOOLEAN      StripQuotation
+  )
+{
+  CONST CHAR16 *NextDelim;
+
+  if (Walker           == NULL
+    ||*Walker          == NULL
+    ||TempParameter    == NULL
+    ||*TempParameter   == NULL
+    ){
+    return (EFI_INVALID_PARAMETER);
+  }
+
+
+  //
+  // make sure we dont have any leading spaces  //  while ((*Walker)[0] 
+ == L' ') {
+      (*Walker)++;
+  }
+
+  //
+  // make sure we still have some params now...
+  //
+  if (StrLen(*Walker) == 0) {
+DEBUG_CODE_BEGIN();
+    *Walker        = NULL;
+DEBUG_CODE_END();
+    return (EFI_INVALID_PARAMETER);
+  }
+
+  NextDelim = FindEndOfParameter(*Walker);
+
+  if (NextDelim == NULL){
+DEBUG_CODE_BEGIN();
+    *Walker        = NULL;
+DEBUG_CODE_END();
+    return (EFI_NOT_FOUND);
+  }
+
+  StrnCpyS(*TempParameter, Length / sizeof(CHAR16), (*Walker), 
+ NextDelim - *Walker);
+
+  //
+  // Add a CHAR_NULL if we didnt get one via the copy  //  if 
+ (*NextDelim != CHAR_NULL) {
+    (*TempParameter)[NextDelim - *Walker] = CHAR_NULL;  }
+
+  //
+  // Update Walker for the next iteration through the function  //  
+ *Walker = (CHAR16*)NextDelim;
+
+  //
+  // Remove any non-escaped quotes in the string  // Remove any 
+ remaining escape characters in the string  //  for (NextDelim = 
+ FindFirstCharacter(*TempParameter, L"\"^", CHAR_NULL)
+    ; *NextDelim != CHAR_NULL 
+    ; NextDelim = FindFirstCharacter(NextDelim, L"\"^", CHAR_NULL)
+    ) {
+    if (*NextDelim == L'^') {
+
+      //
+      // eliminate the escape ^
+      //
+      CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
+      NextDelim++;
+    } else if (*NextDelim == L'\"') {
+
+      //
+      // eliminate the unescaped quote
+      //
+      if (StripQuotation) {
+        CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
+	  } else{
+        NextDelim++;
+	  }
+    }
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
   Function to populate Argc and Argv.
 
   This function parses the CommandLine and divides it into standard C style Argc/Argv @@ -82,7 +238,7 @@ ParseCommandLineToArgs(
       ; Walker != NULL && *Walker != CHAR_NULL
       ; Count++
       ) {
-    if (EFI_ERROR (ShellGetNextParameter (&Walker, TempParameter, Size, TRUE))) {
+    if (EFI_ERROR(GetNextParameter(&Walker, &TempParameter, Size, 
+ TRUE))) {
       break;
     }
   }
@@ -100,7 +256,7 @@ ParseCommandLineToArgs(
   Walker = (CHAR16*)NewCommandLine;
   while(Walker != NULL && *Walker != CHAR_NULL) {
     SetMem16(TempParameter, Size, CHAR_NULL);
-    if (EFI_ERROR (ShellGetNextParameter (&Walker, TempParameter, Size, StripQuotation))) {
+    if (EFI_ERROR(GetNextParameter(&Walker, &TempParameter, Size, 
+ StripQuotation))) {
       Status = EFI_INVALID_PARAMETER;
       goto Done;
     }
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.h b/ShellPkg/Application/Shell/ShellParametersProtocol.h
index 1205d92..926f362 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.h
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.h
@@ -190,5 +190,34 @@ ParseCommandLineToArgs(
   IN OUT UINTN    *Argc
   );
 
+/**
+  return the next parameter from a command line string;
+
+  This function moves the next parameter from Walker into TempParameter 
+ and moves  Walker up past that parameter for recursive calling.  When 
+ the final parameter  is moved *Walker will be set to NULL;
+
+  Temp Parameter must be large enough to hold the parameter before 
+ calling this  function.
+
+  @param[in, out] Walker          pointer to string of command line.  Adjusted to
+                                  reminaing command line on return
+  @param[in, out] TempParameter   pointer to string of command line item extracted.
+  @param[in]      Length          Length of (*TempParameter) in bytes
+  @param[in]      StripQuotation  if TRUE then strip the quotation marks surrounding
+                                  the parameters.
+
+  @return   EFI_INALID_PARAMETER  A required parameter was NULL or pointed to a NULL or empty string.
+  @return   EFI_NOT_FOUND         A closing " could not be found on the specified string
+**/
+EFI_STATUS
+EFIAPI
+GetNextParameter(
+  IN OUT CHAR16   **Walker,
+  IN OUT CHAR16   **TempParameter,
+  IN CONST UINTN  Length,
+  IN BOOLEAN      StripQuotation
+  );
+
 #endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_
 
diff --git a/ShellPkg/Include/Library/ShellCommandLib.h b/ShellPkg/Include/Library/ShellCommandLib.h
index 5c5e241..3ee8200 100644
--- a/ShellPkg/Include/Library/ShellCommandLib.h
+++ b/ShellPkg/Include/Library/ShellCommandLib.h
@@ -719,49 +719,4 @@ CatSDumpHex (
   IN UINTN   DataSize,
   IN VOID    *UserData
   );
-
-/**
-  Return the pointer to the first occurrence of any character from a list of characters.
-
-  @param[in] String                 The string to parse
-  @param[in] CharacterList          The list of character to look for
-  @param[in] IgnoreEscapedCharacter TRUE to ignore escaped characters
-
-  @return The location of the first character in the String.
-  @return Pointer to the ending NULL character of the String.
-**/
-CONST CHAR16*
-EFIAPI
-ShellFindFirstCharacter (
-  IN CONST CHAR16  *String,
-  IN CONST CHAR16  *CharacterList,
-  IN CONST BOOLEAN IgnoreEscapedCharacter
-  );
-
-/**
-  return the next parameter from a command line string;
-
-  This function moves the next parameter from Walker into NextParameter and moves
-  Walker up past that parameter for recursive calling.  When the final parameter
-  is moved *Walker will be set to NULL;
-
-  @param[in, out] Walker          pointer to string of command line.  Adjusted to
-                                  reminaing command line on return
-  @param[in, out] NextParameter   string of command line item extracted.
-  @param[in]      Length          Length of TempParameter in bytes
-  @param[in]      StripQuotation  if TRUE then strip the quotation marks surrounding
-                                  the parameters.
-
-  @return   EFI_INALID_PARAMETER  A required parameter was NULL or pointed to a NULL or empty string.
-  @return   EFI_NOT_FOUND         A closing " could not be found on the specified string
-**/
-EFI_STATUS
-EFIAPI
-ShellGetNextParameter(
-  IN OUT CHAR16   **Walker,
-  IN OUT CHAR16   *NextParameter,
-  IN CONST UINTN  Length,
-  IN BOOLEAN      StripQuotation
-  );
-
 #endif //_SHELL_COMMAND_LIB_
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index ac77111..a97361c 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -83,191 +83,6 @@ CommandInit(
 }
 
 /**
-  Return the pointer to the first occurrence of any character from a list of characters.
-
-  @param[in] String                 The string to parse
-  @param[in] CharacterList          The list of character to look for
-  @param[in] IgnoreEscapedCharacter TRUE to ignore escaped characters
-
-  @return The location of the first character in the String.
-  @return Pointer to the ending NULL character of the String.
-**/
-CONST CHAR16*
-EFIAPI
-ShellFindFirstCharacter (
-  IN CONST CHAR16  *String,
-  IN CONST CHAR16  *CharacterList,
-  IN CONST BOOLEAN IgnoreEscapedCharacter
-  )
-{
-  UINTN WalkChar;
-  UINTN WalkStr;
-
-  for (WalkStr = 0; WalkStr < StrLen (String); WalkStr++) {
-    if (IgnoreEscapedCharacter && (String[WalkStr] == L'^')) {
-      WalkStr++;
-      continue;
-    }
-    for (WalkChar = 0; WalkChar < StrLen (CharacterList); WalkChar++) {
-      if (String[WalkStr] == CharacterList[WalkChar]) {
-        return &String[WalkStr];
-      }
-    }
-  }
-  return &String[WalkStr];
-}
-
-/**
-  Return the next parameter's end from a command line string.
-
-  @param[in] String        the string to parse
-**/
-CONST CHAR16*
-FindEndOfParameter(
-  IN CONST CHAR16 *String
-  )
-{
-  CONST CHAR16 *First;
-  CONST CHAR16 *CloseQuote;
-
-  First = ShellFindFirstCharacter (String, L" \"", TRUE);
-
-  //
-  // nothing, all one parameter remaining
-  //
-  if (*First == CHAR_NULL) {
-    return (First);
-  }
-
-  //
-  // If space before a quote (or neither found, i.e. both CHAR_NULL),
-  // then that's the end.
-  //
-  if (*First == L' ') {
-    return (First);
-  }
-
-  CloseQuote = ShellFindFirstCharacter (First+1, L"\"", TRUE);
-
-  //
-  // We did not find a terminator...
-  //
-  if (*CloseQuote == CHAR_NULL) {
-    return (NULL);
-  }
-
-  return (FindEndOfParameter (CloseQuote+1)); -}
-
-/**
-  Return the next parameter from a command line string.
-
-  This function moves the next parameter from Walker into NextParameter and moves
-  Walker up past that parameter for recursive calling.  When the final parameter
-  is moved *Walker will be set to NULL;
-
-  This will also remove all remaining ^ characters after processing.
-
-  @param[in, out] Walker          pointer to string of command line.  Adjusted to
-                                  reminaing command line on return
-  @param[in, out] NextParameter   pointer to string of command line item extracted.
-  @param[in]      Length          buffer size of TempParameter.
-  @param[in]      StripQuotation  if TRUE then strip the quotation marks surrounding
-                                  the parameters.
-
-  @return   EFI_INALID_PARAMETER  A required parameter was NULL or pointed to a NULL or empty string.
-  @return   EFI_NOT_FOUND         A closing " could not be found on the specified string
-**/
-EFI_STATUS
-EFIAPI
-ShellGetNextParameter (
-  IN OUT CHAR16   **Walker,
-  IN OUT CHAR16   *NextParameter,
-  IN CONST UINTN  Length,
-  IN BOOLEAN      StripQuotation
-  )
-{
-  CONST CHAR16 *NextDelim;
-
-  if (Walker           == NULL
-    ||*Walker          == NULL
-    ||NextParameter    == NULL
-    ){
-    return EFI_INVALID_PARAMETER;
-  }
-
-  //
-  // make sure we dont have any leading spaces
-  //
-  while ((*Walker)[0] == L' ') {
-    (*Walker)++;
-  }
-
-  //
-  // make sure we still have some params now...
-  //
-  if (StrLen(*Walker) == 0) {
-    DEBUG_CODE (
-      *Walker = NULL;
-    );
-    return (EFI_INVALID_PARAMETER);
-  }
-
-  NextDelim = FindEndOfParameter(*Walker);
-
-  if (NextDelim == NULL){
-    DEBUG_CODE (
-      *Walker = NULL;
-    );
-    return (EFI_NOT_FOUND);
-  }
-
-  StrnCpyS(NextParameter, Length / sizeof(CHAR16), (*Walker), NextDelim - *Walker);
-
-  //
-  // Add a CHAR_NULL if we didnt get one via the copy
-  //
-  if (*NextDelim != CHAR_NULL) {
-    NextParameter[NextDelim - *Walker] = CHAR_NULL;
-  }
-
-  //
-  // Update Walker for the next iteration through the function
-  //
-  *Walker = (CHAR16*)NextDelim;
-
-  //
-  // Remove any non-escaped quotes in the string
-  // Remove any remaining escape characters in the string
-  //
-  for (NextDelim = ShellFindFirstCharacter(NextParameter, L"\"^", FALSE)
-    ; *NextDelim != CHAR_NULL
-    ; NextDelim = ShellFindFirstCharacter(NextDelim, L"\"^", FALSE)
-    ) {
-    if (*NextDelim == L'^') {
-
-      //
-      // eliminate the escape ^
-      //
-      CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
-      NextDelim++;
-    } else if (*NextDelim == L'\"') {
-
-      //
-      // eliminate the unescaped quote
-      //
-      if (StripQuotation) {
-        CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
-      } else {
-        NextDelim++;
-      }
-    }
-  }
-
-  return EFI_SUCCESS;
-}
-
-/**
   Constructor for the Shell Command library.
 
   Initialize the library and determine if the underlying is a UEFI Shell 2.0 or an EFI shell.
--
2.9.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter to ShellCommandLib"
  2016-08-23  2:56 ` [PATCH 3/3] Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter " Ruiyu Ni
  2016-08-23 13:45   ` Shah, Tapan
@ 2016-08-24 15:09   ` Shah, Tapan
  1 sibling, 0 replies; 6+ messages in thread
From: Shah, Tapan @ 2016-08-24 15:09 UTC (permalink / raw)
  To: Ruiyu Ni, edk2-devel@lists.01.org; +Cc: Jaben Carsey

Have you already pushed this change?

-----Original Message-----
From: Shah, Tapan 
Sent: Tuesday, August 23, 2016 8:45 AM
To: 'Ruiyu Ni' <ruiyu.ni@intel.com>; edk2-devel@lists.01.org
Cc: Jaben Carsey <jaben.carsey@intel.com>
Subject: RE: [edk2] [PATCH 3/3] Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter to ShellCommandLib"

Series Reviewed By: Tapan Shah <tapandshah@hpe.com>

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Monday, August 22, 2016 9:56 PM
To: edk2-devel@lists.01.org
Cc: Jaben Carsey <jaben.carsey@intel.com>
Subject: [edk2] [PATCH 3/3] Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter to ShellCommandLib"

This reverts commit c0bcd3433f33876c519bf5567e0ab69261b57fe9.
The above commit causes several regression of "echo" command:
1. Double quotes are not being stripped from the final text. UEFI Shell 2.2 section 3.4.5 chops out the quotes.
2. Output redirection is not working as expected. Text is being redirected, but the ‘> …’ text should not be.
3. Inconsistent special character handling.  For example, comments with # seem to be parsed out correctly, but handing of ^ is incorrect.
In summary, ‘echo “You are ^#1” > t.txt’ results in the below content in t.txt:
 “You are ^#1” > t.txt

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 ShellPkg/Application/Shell/Shell.c                 |  81 +++++----
 ShellPkg/Application/Shell/Shell.h                 |  18 ++
 .../Application/Shell/ShellParametersProtocol.c    | 160 +++++++++++++++++-
 .../Application/Shell/ShellParametersProtocol.h    |  29 ++++
 ShellPkg/Include/Library/ShellCommandLib.h         |  45 -----
 .../UefiShellCommandLib/UefiShellCommandLib.c      | 185 ---------------------
 6 files changed, 258 insertions(+), 260 deletions(-)

diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c
index 3080a16..0b6362e 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -213,7 +213,7 @@ ContainsSplit(
 
   FirstQuote    = FindNextInstance (CmdLine, L"\"", TRUE);
   SecondQuote   = NULL;
-  TempSpot      = ShellFindFirstCharacter(CmdLine, L"|", TRUE);
+  TempSpot      = FindFirstCharacter(CmdLine, L"|", L'^');
 
   if (FirstQuote == NULL    || 
       TempSpot == NULL      || 
@@ -236,7 +236,7 @@ ContainsSplit(
       continue;
     } else {
       FirstQuote = FindNextInstance (SecondQuote + 1, L"\"", TRUE);
-      TempSpot = ShellFindFirstCharacter(TempSpot + 1, L"|", TRUE);
+      TempSpot = FindFirstCharacter(TempSpot + 1, L"|", L'^');
       continue;
     } 
   }
@@ -716,7 +716,6 @@ FreeResources:
   }
 
   ShellFreeEnvVarList ();
-  ShellSetRawCmdLine (NULL);
 
   if (ShellCommandGetExit()) {
     return ((EFI_STATUS)ShellCommandGetExitCode());
@@ -1993,7 +1992,7 @@ IsValidSplit(
       return (EFI_OUT_OF_RESOURCES);
     }
     TempWalker = (CHAR16*)Temp;
-    if (!EFI_ERROR (ShellGetNextParameter (&TempWalker, FirstParameter, StrSize(CmdLine), TRUE))) {
+    if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, 
+ StrSize(CmdLine), TRUE))) {
       if (GetOperationType(FirstParameter) == Unknown_Invalid) {
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
         SetLastError(SHELL_NOT_FOUND);
@@ -2042,7 +2041,7 @@ VerifySplit(
   //
   // recurse to verify the next item
   //
-  TempSpot = ShellFindFirstCharacter(CmdLine, L"|", TRUE) + 1;
+  TempSpot = FindFirstCharacter(CmdLine, L"|", L'^') + 1;
   if (*TempSpot == L'a' && 
       (*(TempSpot + 1) == L' ' || *(TempSpot + 1) == CHAR_NULL)
      ) {
@@ -2159,7 +2158,7 @@ DoHelpUpdate(
 
   Walker = *CmdLine;
   while(Walker != NULL && *Walker != CHAR_NULL) {
-    if (!EFI_ERROR (ShellGetNextParameter (&Walker, CurrentParameter, StrSize(*CmdLine), TRUE))) {
+    if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter, 
+ StrSize(*CmdLine), TRUE))) {
       if (StrStr(CurrentParameter, L"-?") == CurrentParameter) {
         CurrentParameter[0] = L' ';
         CurrentParameter[1] = L' ';
@@ -2590,7 +2589,6 @@ RunShellCommand(
   CHAR16                    *FirstParameter;
   CHAR16                    *TempWalker;
   SHELL_OPERATION_TYPES     Type;
-  CHAR16                    *OldCmdLine;
 
   ASSERT(CmdLine != NULL);
   if (StrLen(CmdLine) == 0) {
@@ -2598,14 +2596,11 @@ RunShellCommand(
   }
 
   Status              = EFI_SUCCESS;
-  FirstParameter      = NULL;
   CleanOriginal       = NULL;
-  OldCmdLine          = NULL;
 
   CleanOriginal = StrnCatGrow(&CleanOriginal, NULL, CmdLine, 0);
   if (CleanOriginal == NULL) {
-    Status = EFI_OUT_OF_RESOURCES;
-    goto Done;
+    return (EFI_OUT_OF_RESOURCES);
   }
 
   TrimSpaces(&CleanOriginal);
@@ -2632,36 +2627,35 @@ RunShellCommand(
   // Handle case that passed in command line is just 1 or more " " characters.
   //
   if (StrLen (CleanOriginal) == 0) {
-    Status = EFI_SUCCESS;
-    goto Done;
+    SHELL_FREE_NON_NULL(CleanOriginal);
+    return (EFI_SUCCESS);
   }
 
   Status = ProcessCommandLineToFinal(&CleanOriginal);
   if (EFI_ERROR(Status)) {
-    goto Done;
+    SHELL_FREE_NON_NULL(CleanOriginal);
+    return (Status);
   }
 
-  OldCmdLine = ShellGetRawCmdLine ();
-  ShellSetRawCmdLine (CleanOriginal);
-
   //
   // We don't do normal processing with a split command line (output from one command input to another)
   //
   if (ContainsSplit(CleanOriginal)) {
     Status = ProcessNewSplitCommandLine(CleanOriginal);
-    goto Done;
-  }
+    SHELL_FREE_NON_NULL(CleanOriginal);
+    return (Status);
+  }
 
   //
   // We need the first parameter information so we can determine the operation type
   //
   FirstParameter = AllocateZeroPool(StrSize(CleanOriginal));
   if (FirstParameter == NULL) {
-    Status = EFI_OUT_OF_RESOURCES;
-    goto Done;
+    SHELL_FREE_NON_NULL(CleanOriginal);
+    return (EFI_OUT_OF_RESOURCES);
   }
   TempWalker = CleanOriginal;
-  if (!EFI_ERROR (ShellGetNextParameter (&TempWalker, FirstParameter, StrSize(CleanOriginal), TRUE))) {
+  if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, 
+ StrSize(CleanOriginal), TRUE))) {
     //
     // Depending on the first parameter we change the behavior
     //
@@ -2686,12 +2680,9 @@ RunShellCommand(
     ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
     SetLastError(SHELL_NOT_FOUND);
   }
-
-Done:
-  ShellSetRawCmdLine (OldCmdLine);
-  SHELL_FREE_NON_NULL (OldCmdLine);
-  SHELL_FREE_NON_NULL (CleanOriginal);
-  SHELL_FREE_NON_NULL (FirstParameter);
+ 
+  SHELL_FREE_NON_NULL(CleanOriginal);
+  SHELL_FREE_NON_NULL(FirstParameter);
 
   return (Status);
 }
@@ -3129,3 +3120,37 @@ RunScriptFile (
   return (Status);
 }
 
+/**
+  Return the pointer to the first occurrence of any character from a list of characters.
+
+  @param[in] String           the string to parse
+  @param[in] CharacterList    the list of character to look for
+  @param[in] EscapeCharacter  An escape character to skip
+
+  @return the location of the first character in the string
+  @retval CHAR_NULL no instance of any character in CharacterList was 
+found in String **/ CONST CHAR16* EFIAPI FindFirstCharacter(
+  IN CONST CHAR16 *String,
+  IN CONST CHAR16 *CharacterList,
+  IN CONST CHAR16 EscapeCharacter
+  )
+{
+  UINT32 WalkChar;
+  UINT32 WalkStr;
+
+  for (WalkStr = 0; WalkStr < StrLen(String); WalkStr++) {
+    if (String[WalkStr] == EscapeCharacter) {
+      WalkStr++;
+      continue;
+    }
+    for (WalkChar = 0; WalkChar < StrLen(CharacterList); WalkChar++) {
+      if (String[WalkStr] == CharacterList[WalkChar]) {
+        return (&String[WalkStr]);
+      }
+    }
+  }
+  return (String + StrLen(String));
+}
diff --git a/ShellPkg/Application/Shell/Shell.h b/ShellPkg/Application/Shell/Shell.h
index a34c91a..29b36b0 100644
--- a/ShellPkg/Application/Shell/Shell.h
+++ b/ShellPkg/Application/Shell/Shell.h
@@ -371,6 +371,24 @@ RunScriptFile (
   );
 
 /**
+  Return the pointer to the first occurrence of any character from a list of characters.
+
+  @param[in] String           the string to parse
+  @param[in] CharacterList    the list of character to look for
+  @param[in] EscapeCharacter  An escape character to skip
+
+  @return the location of the first character in the string
+  @retval CHAR_NULL no instance of any character in CharacterList was 
+found in String **/ CONST CHAR16* EFIAPI FindFirstCharacter(
+  IN CONST CHAR16 *String,
+  IN CONST CHAR16 *CharacterList,
+  IN CONST CHAR16 EscapeCharacter
+  );
+
+/**
   Cleans off leading and trailing spaces and tabs.
 
   @param[in] String pointer to the string to trim them off.
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c
index 0785902..3684f9c 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
@@ -20,6 +20,162 @@
 BOOLEAN AsciiRedirection = FALSE;
 
 /**
+  Return the next parameter's end from a command line string.
+
+  @param[in] String        the string to parse
+**/
+CONST CHAR16*
+EFIAPI
+FindEndOfParameter(
+  IN CONST CHAR16 *String
+  )
+{
+  CONST CHAR16 *First;
+  CONST CHAR16 *CloseQuote;
+
+  First = FindFirstCharacter(String, L" \"", L'^');
+
+  //
+  // nothing, all one parameter remaining  //  if (*First == CHAR_NULL) 
+ {
+    return (First);
+  }
+
+  //
+  // If space before a quote (or neither found, i.e. both CHAR_NULL), 
+ // then that's the end.
+  //
+  if (*First == L' ') {
+    return (First);
+  }
+
+  CloseQuote = FindFirstCharacter (First+1, L"\"", L'^');
+
+  //
+  // We did not find a terminator...
+  //
+  if (*CloseQuote == CHAR_NULL) {
+    return (NULL);
+  }
+
+  return (FindEndOfParameter (CloseQuote+1)); }
+
+/**
+  Return the next parameter from a command line string.
+
+  This function moves the next parameter from Walker into TempParameter 
+ and moves  Walker up past that parameter for recursive calling.  When 
+ the final parameter  is moved *Walker will be set to NULL;
+
+  Temp Parameter must be large enough to hold the parameter before 
+ calling this  function.
+
+  This will also remove all remaining ^ characters after processing.
+
+  @param[in, out] Walker          pointer to string of command line.  Adjusted to
+                                  reminaing command line on return
+  @param[in, out] TempParameter   pointer to string of command line item extracted.
+  @param[in]      Length          buffer size of TempParameter.
+  @param[in]      StripQuotation  if TRUE then strip the quotation marks surrounding
+                                  the parameters.
+
+  @return   EFI_INALID_PARAMETER  A required parameter was NULL or pointed to a NULL or empty string.
+  @return   EFI_NOT_FOUND         A closing " could not be found on the specified string
+**/
+EFI_STATUS
+EFIAPI
+GetNextParameter(
+  IN OUT CHAR16   **Walker,
+  IN OUT CHAR16   **TempParameter,
+  IN CONST UINTN  Length,
+  IN BOOLEAN      StripQuotation
+  )
+{
+  CONST CHAR16 *NextDelim;
+
+  if (Walker           == NULL
+    ||*Walker          == NULL
+    ||TempParameter    == NULL
+    ||*TempParameter   == NULL
+    ){
+    return (EFI_INVALID_PARAMETER);
+  }
+
+
+  //
+  // make sure we dont have any leading spaces  //  while ((*Walker)[0] 
+ == L' ') {
+      (*Walker)++;
+  }
+
+  //
+  // make sure we still have some params now...
+  //
+  if (StrLen(*Walker) == 0) {
+DEBUG_CODE_BEGIN();
+    *Walker        = NULL;
+DEBUG_CODE_END();
+    return (EFI_INVALID_PARAMETER);
+  }
+
+  NextDelim = FindEndOfParameter(*Walker);
+
+  if (NextDelim == NULL){
+DEBUG_CODE_BEGIN();
+    *Walker        = NULL;
+DEBUG_CODE_END();
+    return (EFI_NOT_FOUND);
+  }
+
+  StrnCpyS(*TempParameter, Length / sizeof(CHAR16), (*Walker), 
+ NextDelim - *Walker);
+
+  //
+  // Add a CHAR_NULL if we didnt get one via the copy  //  if 
+ (*NextDelim != CHAR_NULL) {
+    (*TempParameter)[NextDelim - *Walker] = CHAR_NULL;  }
+
+  //
+  // Update Walker for the next iteration through the function  // 
+ *Walker = (CHAR16*)NextDelim;
+
+  //
+  // Remove any non-escaped quotes in the string  // Remove any 
+ remaining escape characters in the string  //  for (NextDelim = 
+ FindFirstCharacter(*TempParameter, L"\"^", CHAR_NULL)
+    ; *NextDelim != CHAR_NULL 
+    ; NextDelim = FindFirstCharacter(NextDelim, L"\"^", CHAR_NULL)
+    ) {
+    if (*NextDelim == L'^') {
+
+      //
+      // eliminate the escape ^
+      //
+      CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
+      NextDelim++;
+    } else if (*NextDelim == L'\"') {
+
+      //
+      // eliminate the unescaped quote
+      //
+      if (StripQuotation) {
+        CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
+	  } else{
+        NextDelim++;
+	  }
+    }
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
   Function to populate Argc and Argv.
 
   This function parses the CommandLine and divides it into standard C style Argc/Argv @@ -82,7 +238,7 @@ ParseCommandLineToArgs(
       ; Walker != NULL && *Walker != CHAR_NULL
       ; Count++
       ) {
-    if (EFI_ERROR (ShellGetNextParameter (&Walker, TempParameter, Size, TRUE))) {
+    if (EFI_ERROR(GetNextParameter(&Walker, &TempParameter, Size,
+ TRUE))) {
       break;
     }
   }
@@ -100,7 +256,7 @@ ParseCommandLineToArgs(
   Walker = (CHAR16*)NewCommandLine;
   while(Walker != NULL && *Walker != CHAR_NULL) {
     SetMem16(TempParameter, Size, CHAR_NULL);
-    if (EFI_ERROR (ShellGetNextParameter (&Walker, TempParameter, Size, StripQuotation))) {
+    if (EFI_ERROR(GetNextParameter(&Walker, &TempParameter, Size,
+ StripQuotation))) {
       Status = EFI_INVALID_PARAMETER;
       goto Done;
     }
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.h b/ShellPkg/Application/Shell/ShellParametersProtocol.h
index 1205d92..926f362 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.h
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.h
@@ -190,5 +190,34 @@ ParseCommandLineToArgs(
   IN OUT UINTN    *Argc
   );
 
+/**
+  return the next parameter from a command line string;
+
+  This function moves the next parameter from Walker into TempParameter 
+ and moves  Walker up past that parameter for recursive calling.  When 
+ the final parameter  is moved *Walker will be set to NULL;
+
+  Temp Parameter must be large enough to hold the parameter before 
+ calling this  function.
+
+  @param[in, out] Walker          pointer to string of command line.  Adjusted to
+                                  reminaing command line on return
+  @param[in, out] TempParameter   pointer to string of command line item extracted.
+  @param[in]      Length          Length of (*TempParameter) in bytes
+  @param[in]      StripQuotation  if TRUE then strip the quotation marks surrounding
+                                  the parameters.
+
+  @return   EFI_INALID_PARAMETER  A required parameter was NULL or pointed to a NULL or empty string.
+  @return   EFI_NOT_FOUND         A closing " could not be found on the specified string
+**/
+EFI_STATUS
+EFIAPI
+GetNextParameter(
+  IN OUT CHAR16   **Walker,
+  IN OUT CHAR16   **TempParameter,
+  IN CONST UINTN  Length,
+  IN BOOLEAN      StripQuotation
+  );
+
 #endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_
 
diff --git a/ShellPkg/Include/Library/ShellCommandLib.h b/ShellPkg/Include/Library/ShellCommandLib.h
index 5c5e241..3ee8200 100644
--- a/ShellPkg/Include/Library/ShellCommandLib.h
+++ b/ShellPkg/Include/Library/ShellCommandLib.h
@@ -719,49 +719,4 @@ CatSDumpHex (
   IN UINTN   DataSize,
   IN VOID    *UserData
   );
-
-/**
-  Return the pointer to the first occurrence of any character from a list of characters.
-
-  @param[in] String                 The string to parse
-  @param[in] CharacterList          The list of character to look for
-  @param[in] IgnoreEscapedCharacter TRUE to ignore escaped characters
-
-  @return The location of the first character in the String.
-  @return Pointer to the ending NULL character of the String.
-**/
-CONST CHAR16*
-EFIAPI
-ShellFindFirstCharacter (
-  IN CONST CHAR16  *String,
-  IN CONST CHAR16  *CharacterList,
-  IN CONST BOOLEAN IgnoreEscapedCharacter
-  );
-
-/**
-  return the next parameter from a command line string;
-
-  This function moves the next parameter from Walker into NextParameter and moves
-  Walker up past that parameter for recursive calling.  When the final parameter
-  is moved *Walker will be set to NULL;
-
-  @param[in, out] Walker          pointer to string of command line.  Adjusted to
-                                  reminaing command line on return
-  @param[in, out] NextParameter   string of command line item extracted.
-  @param[in]      Length          Length of TempParameter in bytes
-  @param[in]      StripQuotation  if TRUE then strip the quotation marks surrounding
-                                  the parameters.
-
-  @return   EFI_INALID_PARAMETER  A required parameter was NULL or pointed to a NULL or empty string.
-  @return   EFI_NOT_FOUND         A closing " could not be found on the specified string
-**/
-EFI_STATUS
-EFIAPI
-ShellGetNextParameter(
-  IN OUT CHAR16   **Walker,
-  IN OUT CHAR16   *NextParameter,
-  IN CONST UINTN  Length,
-  IN BOOLEAN      StripQuotation
-  );
-
 #endif //_SHELL_COMMAND_LIB_
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index ac77111..a97361c 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -83,191 +83,6 @@ CommandInit(
 }
 
 /**
-  Return the pointer to the first occurrence of any character from a list of characters.
-
-  @param[in] String                 The string to parse
-  @param[in] CharacterList          The list of character to look for
-  @param[in] IgnoreEscapedCharacter TRUE to ignore escaped characters
-
-  @return The location of the first character in the String.
-  @return Pointer to the ending NULL character of the String.
-**/
-CONST CHAR16*
-EFIAPI
-ShellFindFirstCharacter (
-  IN CONST CHAR16  *String,
-  IN CONST CHAR16  *CharacterList,
-  IN CONST BOOLEAN IgnoreEscapedCharacter
-  )
-{
-  UINTN WalkChar;
-  UINTN WalkStr;
-
-  for (WalkStr = 0; WalkStr < StrLen (String); WalkStr++) {
-    if (IgnoreEscapedCharacter && (String[WalkStr] == L'^')) {
-      WalkStr++;
-      continue;
-    }
-    for (WalkChar = 0; WalkChar < StrLen (CharacterList); WalkChar++) {
-      if (String[WalkStr] == CharacterList[WalkChar]) {
-        return &String[WalkStr];
-      }
-    }
-  }
-  return &String[WalkStr];
-}
-
-/**
-  Return the next parameter's end from a command line string.
-
-  @param[in] String        the string to parse
-**/
-CONST CHAR16*
-FindEndOfParameter(
-  IN CONST CHAR16 *String
-  )
-{
-  CONST CHAR16 *First;
-  CONST CHAR16 *CloseQuote;
-
-  First = ShellFindFirstCharacter (String, L" \"", TRUE);
-
-  //
-  // nothing, all one parameter remaining
-  //
-  if (*First == CHAR_NULL) {
-    return (First);
-  }
-
-  //
-  // If space before a quote (or neither found, i.e. both CHAR_NULL),
-  // then that's the end.
-  //
-  if (*First == L' ') {
-    return (First);
-  }
-
-  CloseQuote = ShellFindFirstCharacter (First+1, L"\"", TRUE);
-
-  //
-  // We did not find a terminator...
-  //
-  if (*CloseQuote == CHAR_NULL) {
-    return (NULL);
-  }
-
-  return (FindEndOfParameter (CloseQuote+1)); -}
-
-/**
-  Return the next parameter from a command line string.
-
-  This function moves the next parameter from Walker into NextParameter and moves
-  Walker up past that parameter for recursive calling.  When the final parameter
-  is moved *Walker will be set to NULL;
-
-  This will also remove all remaining ^ characters after processing.
-
-  @param[in, out] Walker          pointer to string of command line.  Adjusted to
-                                  reminaing command line on return
-  @param[in, out] NextParameter   pointer to string of command line item extracted.
-  @param[in]      Length          buffer size of TempParameter.
-  @param[in]      StripQuotation  if TRUE then strip the quotation marks surrounding
-                                  the parameters.
-
-  @return   EFI_INALID_PARAMETER  A required parameter was NULL or pointed to a NULL or empty string.
-  @return   EFI_NOT_FOUND         A closing " could not be found on the specified string
-**/
-EFI_STATUS
-EFIAPI
-ShellGetNextParameter (
-  IN OUT CHAR16   **Walker,
-  IN OUT CHAR16   *NextParameter,
-  IN CONST UINTN  Length,
-  IN BOOLEAN      StripQuotation
-  )
-{
-  CONST CHAR16 *NextDelim;
-
-  if (Walker           == NULL
-    ||*Walker          == NULL
-    ||NextParameter    == NULL
-    ){
-    return EFI_INVALID_PARAMETER;
-  }
-
-  //
-  // make sure we dont have any leading spaces
-  //
-  while ((*Walker)[0] == L' ') {
-    (*Walker)++;
-  }
-
-  //
-  // make sure we still have some params now...
-  //
-  if (StrLen(*Walker) == 0) {
-    DEBUG_CODE (
-      *Walker = NULL;
-    );
-    return (EFI_INVALID_PARAMETER);
-  }
-
-  NextDelim = FindEndOfParameter(*Walker);
-
-  if (NextDelim == NULL){
-    DEBUG_CODE (
-      *Walker = NULL;
-    );
-    return (EFI_NOT_FOUND);
-  }
-
-  StrnCpyS(NextParameter, Length / sizeof(CHAR16), (*Walker), NextDelim - *Walker);
-
-  //
-  // Add a CHAR_NULL if we didnt get one via the copy
-  //
-  if (*NextDelim != CHAR_NULL) {
-    NextParameter[NextDelim - *Walker] = CHAR_NULL;
-  }
-
-  //
-  // Update Walker for the next iteration through the function
-  //
-  *Walker = (CHAR16*)NextDelim;
-
-  //
-  // Remove any non-escaped quotes in the string
-  // Remove any remaining escape characters in the string
-  //
-  for (NextDelim = ShellFindFirstCharacter(NextParameter, L"\"^", FALSE)
-    ; *NextDelim != CHAR_NULL
-    ; NextDelim = ShellFindFirstCharacter(NextDelim, L"\"^", FALSE)
-    ) {
-    if (*NextDelim == L'^') {
-
-      //
-      // eliminate the escape ^
-      //
-      CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
-      NextDelim++;
-    } else if (*NextDelim == L'\"') {
-
-      //
-      // eliminate the unescaped quote
-      //
-      if (StripQuotation) {
-        CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
-      } else {
-        NextDelim++;
-      }
-    }
-  }
-
-  return EFI_SUCCESS;
-}
-
-/**
   Constructor for the Shell Command library.
 
   Initialize the library and determine if the underlying is a UEFI Shell 2.0 or an EFI shell.
--
2.9.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-08-24 15:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-23  2:56 [PATCH 0/3] Revert "ShellPkg: Fix echo to support displaying special characters" Ruiyu Ni
2016-08-23  2:56 ` [PATCH 1/3] " Ruiyu Ni
2016-08-23  2:56 ` [PATCH 2/3] Revert "ShellPkg: Add Shell[Get|Set]RawCmdLine to ShellCommandLib" Ruiyu Ni
2016-08-23  2:56 ` [PATCH 3/3] Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter " Ruiyu Ni
2016-08-23 13:45   ` Shah, Tapan
2016-08-24 15:09   ` Shah, Tapan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox