]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Move FindFirstCharacter/GetNextParameter to ShellCommandLib
authorRuiyu Ni <ruiyu.ni@intel.com>
Mon, 18 Jul 2016 10:06:33 +0000 (18:06 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Wed, 20 Jul 2016 02:27:51 +0000 (10:27 +0800)
And add Shell prefix to the two library APIs.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Application/Shell/Shell.c
ShellPkg/Application/Shell/Shell.h
ShellPkg/Application/Shell/ShellParametersProtocol.c
ShellPkg/Application/Shell/ShellParametersProtocol.h
ShellPkg/Include/Library/ShellCommandLib.h
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c

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