]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
ShellPkg/Dp: Add null pointer check
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel1CommandsLib / If.c
index f5bc12638bac3ac52007adab60e078e4a653a0d7..35c5ca6835817f942e6044d72c7641c0eb278558 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   Main file for If and else shell level 1 function.\r
 \r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<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
@@ -14,7 +15,6 @@
 \r
 #include "UefiShellLevel1CommandsLib.h"\r
 #include <Library/PrintLib.h>\r
-#include <Library/PathLib.h>\r
 \r
 typedef enum {\r
   EndTagOr,\r
@@ -42,15 +42,17 @@ typedef enum {
 \r
   @param[in, out] Statement    The current remaining statement.\r
   @param[in] Fragment          The current fragment.\r
+  @param[out] Match            TRUE when there is another Fragment in Statement,\r
+                               FALSE otherwise.\r
 \r
-  @retval FALSE   There is not another fragment.\r
-  @retval TRUE    There is another fragment.\r
+  @retval EFI_SUCCESS          The match operation is performed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES Out of resources.\r
 **/\r
-BOOLEAN\r
-EFIAPI\r
+EFI_STATUS\r
 IsNextFragment (\r
   IN OUT CONST CHAR16     **Statement,\r
-  IN CONST CHAR16         *Fragment\r
+  IN CONST CHAR16         *Fragment,\r
+  OUT BOOLEAN             *Match\r
   )\r
 {\r
   CHAR16                  *Tester;\r
@@ -58,7 +60,9 @@ IsNextFragment (
   Tester = NULL;\r
 \r
   Tester = StrnCatGrow(&Tester, NULL, *Statement, StrLen(Fragment));\r
-  ASSERT(Tester != NULL);\r
+  if (Tester == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
   Tester[StrLen(Fragment)] = CHAR_NULL;\r
   if (gUnicodeCollation->StriColl(\r
         gUnicodeCollation,\r
@@ -71,11 +75,12 @@ IsNextFragment (
     while (*Statement[0] == L' ') {\r
       (*Statement)++;\r
     }\r
-    FreePool(Tester);\r
-    return (TRUE);\r
+    *Match = TRUE;\r
+  } else {\r
+    *Match = FALSE;\r
   }\r
   FreePool(Tester);\r
-  return (FALSE);\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
@@ -87,7 +92,6 @@ IsNextFragment (
   @retval FALSE   String is not a valid profile.\r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 IsValidProfile (\r
   IN CONST CHAR16 *String\r
   )\r
@@ -116,7 +120,6 @@ IsValidProfile (
   @return     The result of the comparison.\r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 TestOperation (\r
   IN CONST CHAR16             *Compare1,\r
   IN CONST CHAR16             *Compare2,\r
@@ -346,7 +349,6 @@ TestOperation (
   @retval EFI_SUCCESS             The operation was successful.                                  \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 ProcessStatement (\r
   IN OUT BOOLEAN          *PassingState,\r
   IN UINTN                StartParameterNumber,\r
@@ -365,14 +367,16 @@ ProcessStatement (
   CHAR16                  *Compare2;\r
   CHAR16                  HexString[20];\r
   CHAR16                  *TempSpot;\r
+  BOOLEAN                 Match;\r
 \r
   ASSERT((END_TAG_TYPE)OperatorToUse != EndTagThen);\r
 \r
   Status          = EFI_SUCCESS;\r
   BinOp           = OperatorMax;\r
   OperationResult = FALSE;\r
+  Match           = FALSE;\r
   StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber];\r
-  if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"not")) {\r
+  if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"not", &Match)) && Match) {\r
     NotPresent      = TRUE;\r
     StatementWalker = gEfiShellParametersProtocol->Argv[++StartParameterNumber];\r
   } else {\r
@@ -382,16 +386,19 @@ ProcessStatement (
   //\r
   // now check for 'boolfunc' operators\r
   //\r
-  if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"isint")) {\r
-    if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && StatementWalker[StrLen(StatementWalker)-1] == L')') {\r
+  if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"isint", &Match)) && Match) {\r
+    if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(", &Match)) && Match\r
+        && StatementWalker[StrLen(StatementWalker)-1] == L')') {\r
       StatementWalker[StrLen(StatementWalker)-1] = CHAR_NULL;\r
       OperationResult = ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE);\r
     } else {\r
       Status = EFI_INVALID_PARAMETER;\r
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"isint");\r
     }\r
-  } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"exists") || IsNextFragment((CONST CHAR16**)(&StatementWalker), L"exist")) {\r
-    if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && StatementWalker[StrLen(StatementWalker)-1] == L')') {\r
+  } else if ((!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"exists", &Match)) && Match) ||\r
+             (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"exist", &Match)) && Match)) {\r
+    if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(", &Match)) && Match &&\r
+        StatementWalker[StrLen(StatementWalker)-1] == L')') {\r
       StatementWalker[StrLen(StatementWalker)-1] = CHAR_NULL;\r
       //\r
       // is what remains a file in CWD???\r
@@ -403,8 +410,9 @@ ProcessStatement (
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"exist(s)");\r
       Status = EFI_INVALID_PARAMETER;\r
     }\r
-  } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"available")) {\r
-    if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && StatementWalker[StrLen(StatementWalker)-1] == L')') {\r
+  } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"available", &Match)) && Match) {\r
+    if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(", &Match)) && Match &&\r
+        StatementWalker[StrLen(StatementWalker)-1] == L')') {\r
       StatementWalker[StrLen(StatementWalker)-1] = CHAR_NULL;\r
       //\r
       // is what remains a file in the CWD or path???\r
@@ -414,8 +422,9 @@ ProcessStatement (
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"available");\r
       Status = EFI_INVALID_PARAMETER;\r
     }\r
-  } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"profile")) {\r
-    if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && StatementWalker[StrLen(StatementWalker)-1] == L')') {\r
+  } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"profile", &Match)) && Match) {\r
+    if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(", &Match)) && Match &&\r
+        StatementWalker[StrLen(StatementWalker)-1] == L')') {\r
       //\r
       // Chop off that ')'\r
       //\r
@@ -440,9 +449,9 @@ ProcessStatement (
     // get the first item\r
     //\r
     StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber];\r
-    if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"efierror")) {\r
+    if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"efierror", &Match)) && Match) {\r
       TempSpot = StrStr(StatementWalker, L")");\r
-      if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) {\r
+      if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(", &Match)) && Match && TempSpot != NULL) {\r
         *TempSpot = CHAR_NULL;\r
         if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) {\r
           UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT);\r
@@ -457,9 +466,9 @@ ProcessStatement (
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"efierror");\r
         Status = EFI_INVALID_PARAMETER;\r
       }\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"pierror")) {\r
+    } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"pierror", &Match)) && Match) {\r
       TempSpot = StrStr(StatementWalker, L")");\r
-      if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) {\r
+      if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(", &Match)) && Match && TempSpot != NULL) {\r
         *TempSpot = CHAR_NULL;\r
         if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) {\r
           UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT|(MAX_BIT>>2));\r
@@ -474,9 +483,9 @@ ProcessStatement (
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"pierror");\r
         Status = EFI_INVALID_PARAMETER;\r
       }\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"oemerror")) {\r
+    } else if (!EFI_ERROR (IsNextFragment ((CONST CHAR16**)(&StatementWalker), L"oemerror", &Match)) && Match) {\r
       TempSpot = StrStr(StatementWalker, L")");\r
-      if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) {\r
+      if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(", &Match)) && Match && TempSpot != NULL) {\r
         TempSpot = CHAR_NULL;\r
         if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) {\r
           UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT|(MAX_BIT>>1));\r
@@ -509,27 +518,27 @@ ProcessStatement (
     //\r
     ASSERT(StartParameterNumber+1<EndParameterNumber);\r
     StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber+1];\r
-    if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"gt")) {\r
+    if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"gt", &Match)) && Match) {\r
       BinOp = OperatorGreaterThan;\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"lt")) {\r
+    } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"lt", &Match)) && Match) {\r
       BinOp = OperatorLessThan;\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"eq")) {\r
+    } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"eq", &Match)) && Match) {\r
       BinOp = OperatorEqual;\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ne")) {\r
+    } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ne", &Match)) && Match) {\r
       BinOp = OperatorNotEqual;\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ge")) {\r
+    } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ge", &Match)) && Match) {\r
       BinOp = OperatorGreatorOrEqual;\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"le")) {\r
+    } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"le", &Match)) && Match) {\r
       BinOp = OperatorLessOrEqual;\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"==")) {\r
+    } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"==", &Match)) && Match) {\r
       BinOp = OperatorEqual;\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ugt")) {\r
+    } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ugt", &Match)) && Match) {\r
       BinOp = OperatorUnisgnedGreaterThan;\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ult")) {\r
+    } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ult", &Match)) && Match) {\r
       BinOp = OperatorUnsignedLessThan;\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"uge")) {\r
+    } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"uge", &Match)) && Match) {\r
       BinOp = OperatorUnsignedGreaterOrEqual;\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ule")) {\r
+    } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ule", &Match)) && Match) {\r
       BinOp = OperatorUnsignedLessOrEqual;\r
     } else {\r
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_INVALID_BINOP), gShellLevel1HiiHandle, StatementWalker);\r
@@ -541,9 +550,9 @@ ProcessStatement (
     //\r
     ASSERT(StartParameterNumber+2<=EndParameterNumber);\r
     StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber+2];\r
-    if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"efierror")) {\r
+    if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"efierror", &Match)) && Match) {\r
       TempSpot = StrStr(StatementWalker, L")");\r
-      if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) {\r
+      if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(", &Match)) && Match && TempSpot != NULL) {\r
         TempSpot = CHAR_NULL;\r
         if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) {\r
           UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT);\r
@@ -561,9 +570,9 @@ ProcessStatement (
     //\r
     // can this be collapsed into the above?\r
     //\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"pierror")) {\r
+    } else if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"pierror", &Match)) && Match) {\r
       TempSpot = StrStr(StatementWalker, L")");\r
-      if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) {\r
+      if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(", &Match)) && Match && TempSpot != NULL) {\r
         TempSpot = CHAR_NULL;\r
         if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) {\r
           UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT|(MAX_BIT>>2));\r
@@ -578,9 +587,9 @@ ProcessStatement (
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"pierror");\r
         Status = EFI_INVALID_PARAMETER;\r
       }\r
-    } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"oemerror")) {\r
+    } else if (!EFI_ERROR (IsNextFragment ((CONST CHAR16**)(&StatementWalker), L"oemerror", &Match)) && Match) {\r
       TempSpot = StrStr(StatementWalker, L")");\r
-      if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) {\r
+      if (!EFI_ERROR (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(", &Match)) && Match && TempSpot != NULL) {\r
         TempSpot = CHAR_NULL;\r
         if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) {\r
           UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT|(MAX_BIT>>1));\r
@@ -649,7 +658,6 @@ ProcessStatement (
   @retval FALSE   A valid statement was not found.\r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 BuildNextStatement (\r
   IN UINTN          ParameterNumber,\r
   OUT UINTN         *EndParameter,\r
@@ -701,7 +709,6 @@ BuildNextStatement (
   @retval FALSE    Something went wrong.\r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 MoveToTagSpecial (\r
   IN SCRIPT_FILE                *ScriptFile\r
   )\r
@@ -734,7 +741,11 @@ MoveToTagSpecial (
       continue;\r
     }\r
     CommandWalker = CommandName;\r
-    while (CommandWalker[0] == L' ') {\r
+\r
+    //\r
+    // Skip leading spaces and tabs.\r
+    //\r
+    while ((CommandWalker[0] == L' ') || (CommandWalker[0] == L'\t')) {\r
       CommandWalker++;\r
     }\r
     TempLocation  = StrStr(CommandWalker, L" ");\r
@@ -788,7 +799,6 @@ MoveToTagSpecial (
   @retval EFI_NOT_FOUND     The ending tag could not be found.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 PerformResultOperation (\r
   IN CONST BOOLEAN Result\r
   )\r
@@ -827,12 +837,12 @@ ShellCommandRunIf (
   ASSERT_EFI_ERROR(Status);\r
 \r
   if (!gEfiShellProtocol->BatchIsActive()) {\r
-    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"If");\r
+    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"if");  \r
     return (SHELL_UNSUPPORTED);\r
   }\r
 \r
   if (gEfiShellParametersProtocol->Argc < 3) {\r
-    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle);\r
+    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"if");  \r
     return (SHELL_INVALID_PARAMETER);\r
   }\r
 \r
@@ -847,7 +857,7 @@ ShellCommandRunIf (
       NULL, \r
       STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r
       gShellLevel1HiiHandle, \r
-      L"EnfIf", \r
+      L"EndIf", \r
       L"If", \r
       CurrentScriptFile!=NULL \r
         && CurrentScriptFile->CurrentCommand!=NULL\r
@@ -910,12 +920,12 @@ ShellCommandRunIf (
       // we are at the then\r
       //\r
       if (CurrentParameter+1 != gEfiShellParametersProtocol->Argc) {\r
-        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TEXT_AFTER_THEN), gShellLevel1HiiHandle);\r
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TEXT_AFTER_THEN), gShellLevel1HiiHandle, L"if");  \r
         ShellStatus = SHELL_INVALID_PARAMETER;\r
       } else {\r
         Status = PerformResultOperation(CurrentValue);\r
         if (EFI_ERROR(Status)) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_AFTER_BAD), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[CurrentParameter]);\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_AFTER_BAD), gShellLevel1HiiHandle, L"if", gEfiShellParametersProtocol->Argv[CurrentParameter]);  \r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
         }\r
       }\r
@@ -953,7 +963,7 @@ ShellCommandRunIf (
           if ((Ending == EndTagOr && CurrentValue) || (Ending == EndTagAnd && !CurrentValue)) {\r
             Status = PerformResultOperation(CurrentValue);\r
             if (EFI_ERROR(Status)) {\r
-              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_AFTER_BAD), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[CurrentParameter]);\r
+              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_AFTER_BAD), gShellLevel1HiiHandle, L"if", gEfiShellParametersProtocol->Argv[CurrentParameter]);  \r
               ShellStatus = SHELL_INVALID_PARAMETER;\r
             }\r
             break;\r
@@ -987,11 +997,14 @@ ShellCommandRunElse (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
+  EFI_STATUS  Status;\r
   SCRIPT_FILE *CurrentScriptFile;\r
-  ASSERT_EFI_ERROR(CommandInit());\r
+\r
+  Status = CommandInit ();\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   if (gEfiShellParametersProtocol->Argc > 1) {\r
-    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle);\r
+    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"if");  \r
     return (SHELL_INVALID_PARAMETER);\r
   }\r
 \r
@@ -1062,11 +1075,14 @@ ShellCommandRunEndIf (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
+  EFI_STATUS  Status;\r
   SCRIPT_FILE *CurrentScriptFile;\r
-  ASSERT_EFI_ERROR(CommandInit());\r
+\r
+  Status = CommandInit ();\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   if (gEfiShellParametersProtocol->Argc > 1) {\r
-    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle);\r
+    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"if");  \r
     return (SHELL_INVALID_PARAMETER);\r
   }\r
 \r