And add Shell prefix to the two library APIs.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <[email protected]>
Cc: Jaben Carsey <[email protected]>
---
 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, 260 insertions(+), 258 deletions(-)

diff --git a/ShellPkg/Application/Shell/Shell.c 
b/ShellPkg/Application/Shell/Shell.c
index 54ca76a..d4408b4 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      = FindFirstCharacter(CmdLine, L"|", L'^');
+  TempSpot      = ShellFindFirstCharacter(CmdLine, L"|", TRUE);
 
   if (FirstQuote == NULL    || 
       TempSpot == NULL      || 
@@ -236,7 +236,7 @@ ContainsSplit(
       continue;
     } else {
       FirstQuote = FindNextInstance (SecondQuote + 1, L"\"", TRUE);
-      TempSpot = FindFirstCharacter(TempSpot + 1, L"|", L'^');
+      TempSpot = ShellFindFirstCharacter(TempSpot + 1, L"|", TRUE);
       continue;
     } 
   }
@@ -716,6 +716,7 @@ FreeResources:
   }
 
   ShellFreeEnvVarList ();
+  ShellSetRawCmdLine (NULL);
 
   if (ShellCommandGetExit()) {
     return ((EFI_STATUS)ShellCommandGetExitCode());
@@ -1981,7 +1982,7 @@ IsValidSplit(
       return (EFI_OUT_OF_RESOURCES);
     }
     TempWalker = (CHAR16*)Temp;
-    if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, 
StrSize(CmdLine), TRUE))) {
+    if (!EFI_ERROR (ShellGetNextParameter (&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);
@@ -2030,7 +2031,7 @@ VerifySplit(
   //
   // recurse to verify the next item
   //
-  TempSpot = FindFirstCharacter(CmdLine, L"|", L'^') + 1;
+  TempSpot = ShellFindFirstCharacter(CmdLine, L"|", TRUE) + 1;
   if (*TempSpot == L'a' && 
       (*(TempSpot + 1) == L' ' || *(TempSpot + 1) == CHAR_NULL)
      ) {
@@ -2147,7 +2148,7 @@ DoHelpUpdate(
 
   Walker = *CmdLine;
   while(Walker != NULL && *Walker != CHAR_NULL) {
-    if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter, 
StrSize(*CmdLine), TRUE))) {
+    if (!EFI_ERROR (ShellGetNextParameter (&Walker, CurrentParameter, 
StrSize(*CmdLine), TRUE))) {
       if (StrStr(CurrentParameter, L"-?") == CurrentParameter) {
         CurrentParameter[0] = L' ';
         CurrentParameter[1] = L' ';
@@ -2578,6 +2579,7 @@ RunShellCommand(
   CHAR16                    *FirstParameter;
   CHAR16                    *TempWalker;
   SHELL_OPERATION_TYPES     Type;
+  CHAR16                    *OldCmdLine;
 
   ASSERT(CmdLine != NULL);
   if (StrLen(CmdLine) == 0) {
@@ -2585,11 +2587,14 @@ RunShellCommand(
   }
 
   Status              = EFI_SUCCESS;
+  FirstParameter      = NULL;
   CleanOriginal       = NULL;
+  OldCmdLine          = NULL;
 
   CleanOriginal = StrnCatGrow(&CleanOriginal, NULL, CmdLine, 0);
   if (CleanOriginal == NULL) {
-    return (EFI_OUT_OF_RESOURCES);
+    Status = EFI_OUT_OF_RESOURCES;
+    goto Done;
   }
 
   TrimSpaces(&CleanOriginal);
@@ -2616,35 +2621,36 @@ RunShellCommand(
   // Handle case that passed in command line is just 1 or more " " characters.
   //
   if (StrLen (CleanOriginal) == 0) {
-    SHELL_FREE_NON_NULL(CleanOriginal);
-    return (EFI_SUCCESS);
+    Status = EFI_SUCCESS;
+    goto Done;
   }
 
   Status = ProcessCommandLineToFinal(&CleanOriginal);
   if (EFI_ERROR(Status)) {
-    SHELL_FREE_NON_NULL(CleanOriginal);
-    return (Status);
+    goto Done;
   }
 
+  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);
-    SHELL_FREE_NON_NULL(CleanOriginal);
-    return (Status);
-  } 
+    goto Done;
+  }
 
   //
   // We need the first parameter information so we can determine the operation 
type
   //
   FirstParameter = AllocateZeroPool(StrSize(CleanOriginal));
   if (FirstParameter == NULL) {
-    SHELL_FREE_NON_NULL(CleanOriginal);
-    return (EFI_OUT_OF_RESOURCES);
+    Status = EFI_OUT_OF_RESOURCES;
+    goto Done;
   }
   TempWalker = CleanOriginal;
-  if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, 
StrSize(CleanOriginal), TRUE))) {
+  if (!EFI_ERROR (ShellGetNextParameter (&TempWalker, FirstParameter, 
StrSize(CleanOriginal), TRUE))) {
     //
     // Depending on the first parameter we change the behavior
     //
@@ -2669,9 +2675,12 @@ RunShellCommand(
     ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), 
ShellInfoObject.HiiHandle, FirstParameter);
     SetLastError(SHELL_NOT_FOUND);
   }
- 
-  SHELL_FREE_NON_NULL(CleanOriginal);
-  SHELL_FREE_NON_NULL(FirstParameter);
+
+Done:
+  ShellSetRawCmdLine (OldCmdLine);
+  SHELL_FREE_NON_NULL (OldCmdLine);
+  SHELL_FREE_NON_NULL (CleanOriginal);
+  SHELL_FREE_NON_NULL (FirstParameter);
 
   return (Status);
 }
@@ -3109,37 +3118,3 @@ 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 29b36b0..a34c91a 100644
--- a/ShellPkg/Application/Shell/Shell.h
+++ b/ShellPkg/Application/Shell/Shell.h
@@ -371,24 +371,6 @@ 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 b3767bb..e980ee0 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
@@ -20,162 +20,6 @@
 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
@@ -238,7 +82,7 @@ ParseCommandLineToArgs(
       ; Walker != NULL && *Walker != CHAR_NULL
       ; Count++
       ) {
-    if (EFI_ERROR(GetNextParameter(&Walker, &TempParameter, Size, TRUE))) {
+    if (EFI_ERROR (ShellGetNextParameter (&Walker, TempParameter, Size, 
TRUE))) {
       break;
     }
   }
@@ -256,7 +100,7 @@ ParseCommandLineToArgs(
   Walker = (CHAR16*)NewCommandLine;
   while(Walker != NULL && *Walker != CHAR_NULL) {
     SetMem16(TempParameter, Size, CHAR_NULL);
-    if (EFI_ERROR(GetNextParameter(&Walker, &TempParameter, Size, 
StripQuotation))) {
+    if (EFI_ERROR (ShellGetNextParameter (&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 926f362..1205d92 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.h
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.h
@@ -190,34 +190,5 @@ 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 3ee8200..5c5e241 100644
--- a/ShellPkg/Include/Library/ShellCommandLib.h
+++ b/ShellPkg/Include/Library/ShellCommandLib.h
@@ -719,4 +719,49 @@ 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 0c25528..6283f28 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -83,6 +83,191 @@ 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
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to