]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/Shell/Shell.c
ShellPkg\Application\Shell: Clean start row information after the console has been...
[mirror_edk2.git] / ShellPkg / Application / Shell / Shell.c
index 52b6834ab99ac176829afa8fc0021122aff1c22d..377e1ca7b7e57890bca91eea34826ad03094360b 100644 (file)
@@ -2,7 +2,7 @@
   This is THE shell (application)\r
 \r
   Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
-  (C) Copyright 2013-2014, Hewlett-Packard Development Company, L.P.\r
+  (C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -123,7 +123,7 @@ FindNextInstance(
   Temp = StrStr(SourceString, FindString);\r
 \r
   //\r
-  // If nothing found, or we dont care about escape characters\r
+  // If nothing found, or we don't care about escape characters\r
   //\r
   if (Temp == NULL || !CheckForEscapeCharacter) {\r
     return (Temp);\r
@@ -143,7 +143,7 @@ FindNextInstance(
 }\r
 \r
 /**\r
-  Check whether the string between a pair of % is a valid envifronment variable name.\r
+  Check whether the string between a pair of % is a valid environment variable name.\r
 \r
   @param[in] BeginPercent       pointer to the first percent.\r
   @param[in] EndPercent          pointer to the last percent.\r
@@ -211,21 +211,20 @@ ContainsSplit(
   SecondQuote   = NULL;\r
   TempSpot      = FindFirstCharacter(CmdLine, L"|", L'^');\r
 \r
-  if (FirstQuote == NULL        || \r
-      *FirstQuote == CHAR_NULL  ||\r
-      TempSpot == NULL          || \r
-      *TempSpot == CHAR_NULL    || \r
+  if (FirstQuote == NULL    || \r
+      TempSpot == NULL      || \r
+      TempSpot == CHAR_NULL || \r
       FirstQuote > TempSpot\r
       ) {\r
     return (BOOLEAN) ((TempSpot != NULL) && (*TempSpot != CHAR_NULL));\r
   }\r
 \r
   while ((TempSpot != NULL) && (*TempSpot != CHAR_NULL)) {\r
-    if (FirstQuote == NULL || *FirstQuote == CHAR_NULL || FirstQuote > TempSpot) {\r
+    if (FirstQuote == NULL || FirstQuote > TempSpot) {\r
       break;\r
     }    \r
     SecondQuote = FindNextInstance (FirstQuote + 1, L"\"", TRUE);\r
-    if (SecondQuote == NULL || *SecondQuote == CHAR_NULL) {\r
+    if (SecondQuote == NULL) {\r
       break;\r
     }\r
     if (SecondQuote < TempSpot) {\r
@@ -246,7 +245,7 @@ ContainsSplit(
   feature's enabled state was not known when the shell initially launched.\r
 \r
   @retval EFI_SUCCESS           The feature is enabled.\r
-  @retval EFI_OUT_OF_RESOURCES  There is not enough mnemory available.\r
+  @retval EFI_OUT_OF_RESOURCES  There is not enough memory available.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -685,7 +684,7 @@ FreeResources:
 /**\r
   Sets all the alias' that were registered with the ShellCommandLib library.\r
 \r
-  @retval EFI_SUCCESS           all init commands were run sucessfully.\r
+  @retval EFI_SUCCESS           all init commands were run successfully.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -770,10 +769,10 @@ IsScriptOnlyCommand(
   loaded image protocol installed on it.  The FilePath will point to the device path\r
   for the file that was loaded.\r
 \r
-  @param[in, out] DevPath       On a sucessful return the device path to the loaded image.\r
-  @param[in, out] FilePath      On a sucessful return the device path to the file.\r
+  @param[in, out] DevPath       On a successful return the device path to the loaded image.\r
+  @param[in, out] FilePath      On a successful return the device path to the file.\r
 \r
-  @retval EFI_SUCCESS           The 2 device paths were sucessfully returned.\r
+  @retval EFI_SUCCESS           The 2 device paths were successfully returned.\r
   @retval other                 A error from gBS->HandleProtocol.\r
 \r
   @sa HandleProtocol\r
@@ -980,7 +979,7 @@ ProcessCommandLine(
                                    ) == 0) {\r
       ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit         = TRUE;\r
     } else if (StrnCmp (L"-", CurrentArg, 1) == 0) {\r
-      // Unrecognised option\r
+      // Unrecognized option\r
       ShellPrintHiiEx(-1, -1, NULL,\r
         STRING_TOKEN (STR_GEN_PROBLEM),\r
         ShellInfoObject.HiiHandle,\r
@@ -1168,7 +1167,7 @@ DoStartupScript(
     FileStringPath = ShellFindFilePath(mStartupScript);\r
     if (FileStringPath == NULL) {\r
       //\r
-      // we return success since we dont need to have a startup script\r
+      // we return success since we don't need to have a startup script\r
       //\r
       Status = EFI_SUCCESS;\r
       ASSERT(FileHandle == NULL);\r
@@ -1350,7 +1349,7 @@ StripUnreplacedEnvironmentVariables(
     SecondPercent = FirstPercent!=NULL?FindNextInstance(FirstPercent+1, L"%", TRUE):NULL;\r
     if (FirstPercent == NULL || SecondPercent == NULL) {\r
       //\r
-      // If we ever dont have 2 % we are done.\r
+      // If we ever don't have 2 % we are done.\r
       //\r
       break;\r
     }\r
@@ -1375,14 +1374,14 @@ StripUnreplacedEnvironmentVariables(
       continue;\r
     }\r
     \r
-    if (FirstQuote == NULL || *FirstQuote == CHAR_NULL || SecondPercent < FirstQuote) {\r
+    if (FirstQuote == NULL || SecondPercent < FirstQuote) {\r
       if (IsValidEnvironmentVariableName(FirstPercent, SecondPercent)) {\r
         //\r
         // We need to remove from FirstPercent to SecondPercent\r
         //\r
         CopyMem(FirstPercent, SecondPercent + 1, StrSize(SecondPercent + 1));\r
         //\r
-        // dont need to update the locator.  both % characters are gone.\r
+        // don't need to update the locator.  both % characters are gone.\r
         //\r
       } else {\r
         CurrentLocator = SecondPercent + 1;\r
@@ -1402,7 +1401,7 @@ StripUnreplacedEnvironmentVariables(
 \r
   @param[in] OriginalCommandLine    The original command line\r
 \r
-  @retval NULL                      An error ocurred.\r
+  @retval NULL                      An error occurred.\r
   @return                           The new command line with no environment variables present.\r
 **/\r
 CHAR16*\r
@@ -1443,7 +1442,7 @@ ShellConvertVariables (
         ;  Temp = StrStr(Temp+1, AliasListNode->Alias)\r
        ){\r
         //\r
-        // we need a preceeding and if there is space no ^ preceeding (if no space ignore)\r
+        // we need a preceding and if there is space no ^ preceding (if no space ignore)\r
         //\r
         if ((((Temp-OriginalCommandLine)>2) && *(Temp-2) != L'^') || ((Temp-OriginalCommandLine)<=2)) {\r
           NewSize += StrSize(AliasListNode->CommandString);\r
@@ -1464,7 +1463,7 @@ ShellConvertVariables (
       ;  Temp = StrStr(Temp+1, MasterEnvList)\r
      ){\r
       //\r
-      // we need a preceeding and following % and if there is space no ^ preceeding (if no space ignore)\r
+      // we need a preceding and following % and if there is space no ^ preceding (if no space ignore)\r
       //\r
       if (*(Temp-1) == L'%' && *(Temp+StrLen(MasterEnvList)) == L'%' &&\r
         ((((Temp-OriginalCommandLine)>2) && *(Temp-2) != L'^') || ((Temp-OriginalCommandLine)<=2))) {\r
@@ -1506,7 +1505,7 @@ ShellConvertVariables (
   }\r
 \r
   //\r
-  // Remove non-existant environment variables\r
+  // Remove non-existent environment variables\r
   //\r
   StripUnreplacedEnvironmentVariables(NewCommandLine1);\r
 \r
@@ -1903,7 +1902,7 @@ VerifySplit(
   @param[in] CmdLine    pointer to the command line to process\r
 \r
   @retval EFI_SUCCESS   The operation was successful\r
-  @return               an error occured.\r
+  @return               an error occurred.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -1990,7 +1989,6 @@ DoHelpUpdate(
 {\r
   CHAR16 *CurrentParameter;\r
   CHAR16 *Walker;\r
-  CHAR16 *LastWalker;\r
   CHAR16 *NewCommandLine;\r
   EFI_STATUS Status;\r
 \r
@@ -2003,11 +2001,10 @@ DoHelpUpdate(
 \r
   Walker = *CmdLine;\r
   while(Walker != NULL && *Walker != CHAR_NULL) {\r
-    LastWalker = Walker;\r
     if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter, StrSize(*CmdLine)))) {\r
       if (StrStr(CurrentParameter, L"-?") == CurrentParameter) {\r
-        LastWalker[0] = L' ';\r
-        LastWalker[1] = L' ';\r
+        CurrentParameter[0] = L' ';\r
+        CurrentParameter[1] = L' ';\r
         NewCommandLine = AllocateZeroPool(StrSize(L"help ") + StrSize(*CmdLine));\r
         if (NewCommandLine == NULL) {\r
           Status = EFI_OUT_OF_RESOURCES;\r
@@ -2061,7 +2058,7 @@ SetLastError(
 \r
   @retval EFI_SUCCESS           The operation was successful\r
   @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.\r
-  @return                       some other error occured\r
+  @return                       some other error occurred\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -2106,7 +2103,7 @@ ProcessCommandLineToFinal(
 /**\r
   Run an internal shell command.\r
 \r
-  This API will upadate the shell's environment since these commands are libraries.\r
+  This API will update the shell's environment since these commands are libraries.\r
   \r
   @param[in] CmdLine          the command line to run.\r
   @param[in] FirstParameter   the first parameter on the command line\r
@@ -2184,13 +2181,13 @@ RunInternalCommand(
   }\r
 \r
   //\r
-  // This is guarenteed to be called after UpdateArgcArgv no matter what else happened.\r
+  // This is guaranteed to be called after UpdateArgcArgv no matter what else happened.\r
   // This is safe even if the update API failed.  In this case, it may be a no-op.\r
   //\r
   RestoreArgcArgv(ParamProtocol, &Argv, &Argc);\r
 \r
   //\r
-  // If a script is running and the command is not a scipt only command, then\r
+  // If a script is running and the command is not a script only command, then\r
   // change return value to success so the script won't halt (unless aborted).\r
   //\r
   // Script only commands have to be able halt the script since the script will\r
@@ -2428,7 +2425,7 @@ RunCommand(
   // NULL out comments (leveraged from RunScriptFileHandle() ).\r
   // The # character on a line is used to denote that all characters on the same line\r
   // and to the right of the # are to be ignored by the shell.\r
-  // Afterward, again remove spaces, in case any were between the last command-parameter and '#'.\r
+  // Afterwards, again remove spaces, in case any were between the last command-parameter and '#'.\r
   //\r
   for (TempWalker = CleanOriginal; TempWalker != NULL && *TempWalker != CHAR_NULL; TempWalker++) {\r
     if (*TempWalker == L'^') {\r
@@ -2457,7 +2454,7 @@ RunCommand(
   }\r
 \r
   //\r
-  // We dont do normal processing with a split command line (output from one command input to another)\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
@@ -2508,7 +2505,7 @@ RunCommand(
 \r
 STATIC CONST UINT16 InvalidChars[] = {L'*', L'?', L'<', L'>', L'\\', L'/', L'\"', 0x0001, 0x0002};\r
 /**\r
-  Function determins if the CommandName COULD be a valid command.  It does not determine whether\r
+  Function determines if the CommandName COULD be a valid command.  It does not determine whether\r
   this is a valid command.  It only checks for invalid characters.\r
 \r
   @param[in] CommandName    The name to check\r
@@ -2544,7 +2541,7 @@ IsValidCommandName(
   @param[in] Handle             The handle to the already opened file.\r
   @param[in] Name               The name of the script file.\r
 \r
-  @retval EFI_SUCCESS           the script completed sucessfully\r
+  @retval EFI_SUCCESS           the script completed successfully\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -2840,7 +2837,7 @@ RunScriptFileHandle (
   @param[in] CmdLine            the command line to run.\r
   @param[in] ParamProtocol      the shell parameters protocol pointer\r
 \r
-  @retval EFI_SUCCESS           the script completed sucessfully\r
+  @retval EFI_SUCCESS           the script completed successfully\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -2888,7 +2885,7 @@ RunScriptFile (
   }\r
 \r
   //\r
-  // This is guarenteed to be called after UpdateArgcArgv no matter what else happened.\r
+  // This is guaranteed to be called after UpdateArgcArgv no matter what else happened.\r
   // This is safe even if the update API failed.  In this case, it may be a no-op.\r
   //\r
   RestoreArgcArgv(ParamProtocol, &Argv, &Argc);\r
@@ -2897,7 +2894,7 @@ RunScriptFile (
 }\r
 \r
 /**\r
-  Return the pointer to the first occurance of any character from a list of characters.\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
@@ -2929,4 +2926,4 @@ FindFirstCharacter(
     }\r
   }\r
   return (String + StrLen(String));\r
-}
\ No newline at end of file
+}\r