/** @file\r
This is THE shell (application)\r
\r
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\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
0,\r
0,\r
0,\r
+ 0,\r
0\r
}},\r
0,\r
STATIC CONST CHAR16 mScriptExtension[] = L".NSH";\r
STATIC CONST CHAR16 mExecutableExtensions[] = L".NSH;.EFI";\r
STATIC CONST CHAR16 mStartupScript[] = L"startup.nsh";\r
+CONST CHAR16 mNoNestingEnvVarName[] = L"nonesting";\r
+CONST CHAR16 mNoNestingTrue[] = L"True";\r
+CONST CHAR16 mNoNestingFalse[] = L"False";\r
\r
/**\r
Cleans off leading and trailing spaces and tabs.\r
Status = CommandInit();\r
ASSERT_EFI_ERROR(Status);\r
\r
+ Status = ShellInitEnvVarList ();\r
+\r
//\r
// Check the command line\r
//\r
Status = ShellCommandCreateInitialMappingsAndPaths();\r
}\r
\r
+ //\r
+ // Set the environment variable for nesting support\r
+ //\r
+ Size = 0;\r
+ TempString = NULL;\r
+ if (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest) {\r
+ //\r
+ // No change. require nesting in Shell Protocol Execute()\r
+ //\r
+ StrnCatGrow(&TempString,\r
+ &Size,\r
+ L"False",\r
+ 0);\r
+ } else {\r
+ StrnCatGrow(&TempString,\r
+ &Size,\r
+ mNoNestingTrue,\r
+ 0);\r
+ }\r
+ Status = InternalEfiShellSetEnv(mNoNestingEnvVarName, TempString, TRUE);\r
+ SHELL_FREE_NON_NULL(TempString);\r
+ Size = 0;\r
+\r
//\r
// save the device path for the loaded image and the device path for the filepath (under loaded image)\r
// These are where to look for the startup.nsh file\r
DEBUG_CODE(ShellInfoObject.ConsoleInfo = NULL;);\r
}\r
\r
+ ShellFreeEnvVarList ();\r
+\r
if (ShellCommandGetExit()) {\r
return ((EFI_STATUS)ShellCommandGetExitCode());\r
}\r
// like a shell option (which is assumed to be `file-name`).\r
\r
Status = gBS->LocateProtocol (\r
- &gEfiUnicodeCollationProtocolGuid,\r
+ &gEfiUnicodeCollation2ProtocolGuid,\r
NULL,\r
(VOID **) &UnicodeCollation\r
);\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ Status = gBS->LocateProtocol (\r
+ &gEfiUnicodeCollationProtocolGuid,\r
+ NULL,\r
+ (VOID **) &UnicodeCollation\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
}\r
\r
// Set default options\r
ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoVersion = FALSE;\r
ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay = FALSE;\r
ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit = FALSE;\r
+ ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest = FALSE;\r
ShellInfoObject.ShellInitSettings.Delay = 5;\r
\r
//\r
) == 0) {\r
ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoVersion = TRUE;\r
}\r
+ else if (UnicodeCollation->StriColl (\r
+ UnicodeCollation,\r
+ L"-nonest",\r
+ CurrentArg\r
+ ) == 0) {\r
+ ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest = TRUE;\r
+ }\r
else if (UnicodeCollation->StriColl (\r
UnicodeCollation,\r
L"-delay",\r
)\r
{\r
EFI_STATUS Status;\r
+ EFI_STATUS CalleeStatus;\r
UINTN Delay;\r
EFI_INPUT_KEY Key;\r
SHELL_FILE_HANDLE FileHandle;\r
StrnCatS(FileStringPath, NewSize/sizeof(CHAR16), L" ", NewSize/sizeof(CHAR16) - StrLen(FileStringPath) -1);\r
StrnCatS(FileStringPath, NewSize/sizeof(CHAR16), ShellInfoObject.ShellInitSettings.FileOptions, NewSize/sizeof(CHAR16) - StrLen(FileStringPath) -1);\r
}\r
- Status = RunCommand(FileStringPath);\r
+ Status = RunShellCommand(FileStringPath, &CalleeStatus);\r
+ if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit == TRUE) {\r
+ ShellCommandRegisterExit(gEfiShellProtocol->BatchIsActive(), (UINT64)CalleeStatus);\r
+ }\r
FreePool(FileStringPath);\r
return (Status);\r
\r
CONST CHAR16 *CurDir;\r
UINTN BufferSize;\r
EFI_STATUS Status;\r
+ LIST_ENTRY OldBufferList;\r
\r
CurDir = NULL;\r
\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
+ SaveBufferList(&OldBufferList);\r
CurDir = ShellInfoObject.NewEfiShellProtocol->GetEnv(L"cwd");\r
\r
//\r
//\r
// Done with this command\r
//\r
+ RestoreBufferList(&OldBufferList);\r
FreePool (CmdLine);\r
return Status;\r
}\r
return (Buffer);\r
}\r
\r
+\r
+/**\r
+ Create a new buffer list and stores the old one to OldBufferList \r
+\r
+ @param OldBufferList The temporary list head used to store the nodes in BufferToFreeList.\r
+**/\r
+VOID\r
+SaveBufferList (\r
+ OUT LIST_ENTRY *OldBufferList\r
+ )\r
+{\r
+ CopyMem (OldBufferList, &ShellInfoObject.BufferToFreeList.Link, sizeof (LIST_ENTRY));\r
+ InitializeListHead (&ShellInfoObject.BufferToFreeList.Link);\r
+}\r
+\r
+/**\r
+ Restore previous nodes into BufferToFreeList .\r
+\r
+ @param OldBufferList The temporary list head used to store the nodes in BufferToFreeList.\r
+**/\r
+VOID\r
+RestoreBufferList (\r
+ IN OUT LIST_ENTRY *OldBufferList\r
+ )\r
+{\r
+ FreeBufferList (&ShellInfoObject.BufferToFreeList);\r
+ CopyMem (&ShellInfoObject.BufferToFreeList.Link, OldBufferList, sizeof (LIST_ENTRY));\r
+}\r
+\r
+\r
/**\r
Add a buffer to the Line History List\r
\r
)\r
{\r
BUFFER_LIST *Node;\r
+ BUFFER_LIST *Walker;\r
+ UINT16 MaxHistoryCmdCount;\r
+ UINT16 Count;\r
+\r
+ Count = 0;\r
+ MaxHistoryCmdCount = PcdGet16(PcdShellMaxHistoryCommandCount);\r
+ \r
+ if (MaxHistoryCmdCount == 0) {\r
+ return ;\r
+ }\r
+\r
\r
Node = AllocateZeroPool(sizeof(BUFFER_LIST));\r
ASSERT(Node != NULL);\r
Node->Buffer = AllocateCopyPool(StrSize(Buffer), Buffer);\r
ASSERT(Node->Buffer != NULL);\r
\r
- InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);\r
+ for ( Walker = (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link)\r
+ ; !IsNull(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Walker->Link)\r
+ ; Walker = (BUFFER_LIST*)GetNextNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Walker->Link)\r
+ ){\r
+ Count++;\r
+ }\r
+ if (Count < MaxHistoryCmdCount){\r
+ InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);\r
+ } else {\r
+ Walker = (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link);\r
+ RemoveEntryList(&Walker->Link);\r
+ if (Walker->Buffer != NULL) {\r
+ FreePool(Walker->Buffer);\r
+ }\r
+ FreePool(Walker);\r
+ InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);\r
+ }\r
}\r
\r
/**\r
SHELL_FREE_NON_NULL(OurCommandLine);\r
SHELL_FREE_NON_NULL(NextCommandLine);\r
return (EFI_INVALID_PARAMETER);\r
- } else if (NextCommandLine[0] != CHAR_NULL &&\r
- NextCommandLine[0] == L'a' &&\r
- NextCommandLine[1] == L' '\r
- ){\r
+ } else if (NextCommandLine[0] == L'a' &&\r
+ (NextCommandLine[1] == L' ' || NextCommandLine[1] == CHAR_NULL)\r
+ ){\r
CopyMem(NextCommandLine, NextCommandLine+1, StrSize(NextCommandLine) - sizeof(NextCommandLine[0]));\r
+ while (NextCommandLine[0] == L' ') {\r
+ CopyMem(NextCommandLine, NextCommandLine+1, StrSize(NextCommandLine) - sizeof(NextCommandLine[0]));\r
+ }\r
+ if (NextCommandLine[0] == CHAR_NULL) {\r
+ SHELL_FREE_NON_NULL(OurCommandLine);\r
+ SHELL_FREE_NON_NULL(NextCommandLine);\r
+ return (EFI_INVALID_PARAMETER);\r
+ }\r
Unicode = FALSE;\r
} else {\r
Unicode = TRUE;\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
TempWalker = (CHAR16*)Temp;\r
- if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, StrSize(CmdLine)))) {\r
+ if (!EFI_ERROR(GetNextParameter(&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
EFI_STATUS Status;\r
\r
//\r
- // Verify up to the pipe or end character\r
+ // If this was the only item, then get out\r
//\r
- Status = IsValidSplit(CmdLine);\r
- if (EFI_ERROR(Status)) {\r
- return (Status);\r
+ if (!ContainsSplit(CmdLine)) {\r
+ return (EFI_SUCCESS);\r
}\r
\r
//\r
- // If this was the only item, then get out\r
+ // Verify up to the pipe or end character\r
//\r
- if (!ContainsSplit(CmdLine)) {\r
- return (EFI_SUCCESS);\r
+ Status = IsValidSplit(CmdLine);\r
+ if (EFI_ERROR(Status)) {\r
+ return (Status);\r
}\r
\r
//\r
// recurse to verify the next item\r
//\r
TempSpot = FindFirstCharacter(CmdLine, L"|", L'^') + 1;\r
+ if (*TempSpot == L'a' && \r
+ (*(TempSpot + 1) == L' ' || *(TempSpot + 1) == CHAR_NULL)\r
+ ) {\r
+ // If it's an ASCII pipe '|a'\r
+ TempSpot += 1;\r
+ }\r
+ \r
return (VerifySplit(TempSpot));\r
}\r
\r
\r
Walker = *CmdLine;\r
while(Walker != NULL && *Walker != CHAR_NULL) {\r
- if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter, StrSize(*CmdLine)))) {\r
+ if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter, StrSize(*CmdLine), TRUE))) {\r
if (StrStr(CurrentParameter, L"-?") == CurrentParameter) {\r
CurrentParameter[0] = L' ';\r
CurrentParameter[1] = L' ';\r
@param[in] CmdLine the command line to run.\r
@param[in] FirstParameter the first parameter on the command line\r
@param[in] ParamProtocol the shell parameters protocol pointer\r
+ @param[out] CommandStatus the status from the command line.\r
\r
@retval EFI_SUCCESS The command was completed.\r
@retval EFI_ABORTED The command's operation was aborted.\r
RunInternalCommand(\r
IN CONST CHAR16 *CmdLine,\r
IN CHAR16 *FirstParameter,\r
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol\r
+ IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol,\r
+ OUT EFI_STATUS *CommandStatus\r
)\r
{\r
EFI_STATUS Status;\r
//\r
// get the argc and argv updated for internal commands\r
//\r
- Status = UpdateArgcArgv(ParamProtocol, NewCmdLine, &Argv, &Argc);\r
+ Status = UpdateArgcArgv(ParamProtocol, NewCmdLine, Internal_Command, &Argv, &Argc);\r
if (!EFI_ERROR(Status)) {\r
//\r
// Run the internal command.\r
Status = ShellCommandRunCommandHandler(FirstParameter, &CommandReturnedStatus, &LastError);\r
\r
if (!EFI_ERROR(Status)) {\r
+ if (CommandStatus != NULL) {\r
+ if (CommandReturnedStatus != SHELL_SUCCESS) {\r
+ *CommandStatus = (EFI_STATUS)(CommandReturnedStatus | MAX_BIT);\r
+ } else {\r
+ *CommandStatus = EFI_SUCCESS;\r
+ }\r
+ }\r
+\r
//\r
// Update last error status.\r
// some commands do not update last error.\r
@param[in] CmdLine the command line to run.\r
@param[in] FirstParameter the first parameter on the command line\r
@param[in] ParamProtocol the shell parameters protocol pointer\r
+ @param[out] CommandStatus the status from the command line.\r
\r
@retval EFI_SUCCESS The command was completed.\r
@retval EFI_ABORTED The command's operation was aborted.\r
IN SHELL_OPERATION_TYPES Type,\r
IN CONST CHAR16 *CmdLine,\r
IN CHAR16 *FirstParameter,\r
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol\r
+ IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol,\r
+ OUT EFI_STATUS *CommandStatus\r
)\r
{\r
EFI_STATUS Status;\r
\r
switch (Type) {\r
case Internal_Command:\r
- Status = RunInternalCommand(CmdLine, FirstParameter, ParamProtocol);\r
+ Status = RunInternalCommand(CmdLine, FirstParameter, ParamProtocol, CommandStatus);\r
break;\r
case Script_File_Name:\r
case Efi_Application:\r
CalleeExitStatus = (SHELL_STATUS) StartStatus;\r
}\r
\r
+ if (CommandStatus != NULL) {\r
+ *CommandStatus = CalleeExitStatus;\r
+ }\r
+\r
//\r
// Update last error status.\r
//\r
@param[in] CmdLine the command line to run.\r
@param[in] FirstParameter the first parameter on the command line.\r
@param[in] ParamProtocol the shell parameters protocol pointer\r
+ @param[out] CommandStatus the status from the command line.\r
\r
@retval EFI_SUCCESS The command was completed.\r
@retval EFI_ABORTED The command's operation was aborted.\r
EFI_STATUS\r
EFIAPI\r
SetupAndRunCommandOrFile(\r
- IN SHELL_OPERATION_TYPES Type,\r
- IN CHAR16 *CmdLine,\r
- IN CHAR16 *FirstParameter,\r
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol\r
+ IN SHELL_OPERATION_TYPES Type,\r
+ IN CHAR16 *CmdLine,\r
+ IN CHAR16 *FirstParameter,\r
+ IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol,\r
+ OUT EFI_STATUS *CommandStatus\r
)\r
{\r
EFI_STATUS Status;\r
SHELL_FILE_HANDLE OriginalStdOut;\r
SHELL_FILE_HANDLE OriginalStdErr;\r
SYSTEM_TABLE_INFO OriginalSystemTableInfo;\r
+ CONST SCRIPT_FILE *ConstScriptFile;\r
\r
//\r
// Update the StdIn, StdOut, and StdErr for redirection to environment variables, files, etc... unicode and ASCII\r
//\r
if (!EFI_ERROR(Status)) {\r
TrimSpaces(&CmdLine);\r
- Status = RunCommandOrFile(Type, CmdLine, FirstParameter, ParamProtocol);\r
+ Status = RunCommandOrFile(Type, CmdLine, FirstParameter, ParamProtocol, CommandStatus);\r
}\r
\r
//\r
// Now print errors\r
//\r
if (EFI_ERROR(Status)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_ERROR), ShellInfoObject.HiiHandle, (VOID*)(Status));\r
+ ConstScriptFile = ShellCommandGetCurrentScriptFile();\r
+ if (ConstScriptFile == NULL || ConstScriptFile->CurrentCommand == NULL) {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_ERROR), ShellInfoObject.HiiHandle, (VOID*)(Status));\r
+ } else {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_ERROR_SCRIPT), ShellInfoObject.HiiHandle, (VOID*)(Status), ConstScriptFile->CurrentCommand->Line);\r
+ }\r
}\r
\r
//\r
command or dispatch an external application.\r
\r
@param[in] CmdLine The command line to parse.\r
+ @param[out] CommandStatus The status from the command line.\r
\r
@retval EFI_SUCCESS The command was completed.\r
@retval EFI_ABORTED The command's operation was aborted.\r
**/\r
EFI_STATUS\r
EFIAPI\r
-RunCommand(\r
- IN CONST CHAR16 *CmdLine\r
+RunShellCommand(\r
+ IN CONST CHAR16 *CmdLine,\r
+ OUT EFI_STATUS *CommandStatus\r
)\r
{\r
EFI_STATUS Status;\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
TempWalker = CleanOriginal;\r
- if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, StrSize(CleanOriginal)))) {\r
+ if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, StrSize(CleanOriginal), TRUE))) {\r
//\r
// Depending on the first parameter we change the behavior\r
//\r
case Internal_Command:\r
case Script_File_Name:\r
case Efi_Application:\r
- Status = SetupAndRunCommandOrFile(Type, CleanOriginal, FirstParameter, ShellInfoObject.NewShellParametersProtocol);\r
+ Status = SetupAndRunCommandOrFile(Type, CleanOriginal, FirstParameter, ShellInfoObject.NewShellParametersProtocol, CommandStatus);\r
break;\r
default:\r
//\r
return (Status);\r
}\r
\r
+/**\r
+ Function will process and run a command line.\r
+\r
+ This will determine if the command line represents an internal shell \r
+ command or dispatch an external application.\r
+\r
+ @param[in] CmdLine The command line to parse.\r
+\r
+ @retval EFI_SUCCESS The command was completed.\r
+ @retval EFI_ABORTED The command's operation was aborted.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RunCommand(\r
+ IN CONST CHAR16 *CmdLine\r
+ )\r
+{\r
+ return (RunShellCommand(CmdLine, NULL));\r
+}\r
+\r
+\r
STATIC CONST UINT16 InvalidChars[] = {L'*', L'?', L'<', L'>', L'\\', L'/', L'\"', 0x0001, 0x0002};\r
/**\r
Function determines if the CommandName COULD be a valid command. It does not determine whether\r
EFI_STATUS Status;\r
SCRIPT_FILE *NewScriptFile;\r
UINTN LoopVar;\r
+ UINTN PrintBuffSize;\r
CHAR16 *CommandLine;\r
CHAR16 *CommandLine2;\r
CHAR16 *CommandLine3;\r
CONST CHAR16 *CurDir;\r
UINTN LineCount;\r
CHAR16 LeString[50];\r
+ LIST_ENTRY OldBufferList;\r
\r
ASSERT(!ShellCommandGetScriptExit());\r
\r
PreScriptEchoState = ShellCommandGetEchoState();\r
+ PrintBuffSize = PcdGet16(PcdShellPrintBufferSize);\r
\r
NewScriptFile = (SCRIPT_FILE*)AllocateZeroPool(sizeof(SCRIPT_FILE));\r
if (NewScriptFile == NULL) {\r
//\r
// Now enumerate through the commands and run each one.\r
//\r
- CommandLine = AllocateZeroPool(PcdGet16(PcdShellPrintBufferSize));\r
+ CommandLine = AllocateZeroPool(PrintBuffSize);\r
if (CommandLine == NULL) {\r
DeleteScriptFileStruct(NewScriptFile);\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
- CommandLine2 = AllocateZeroPool(PcdGet16(PcdShellPrintBufferSize));\r
+ CommandLine2 = AllocateZeroPool(PrintBuffSize);\r
if (CommandLine2 == NULL) {\r
FreePool(CommandLine);\r
DeleteScriptFileStruct(NewScriptFile);\r
; // conditional increment in the body of the loop\r
){\r
ASSERT(CommandLine2 != NULL);\r
- StrCpyS( CommandLine2, \r
- PcdGet16(PcdShellPrintBufferSize)/sizeof(CHAR16), \r
- NewScriptFile->CurrentCommand->Cl\r
+ StrnCpyS( CommandLine2, \r
+ PrintBuffSize/sizeof(CHAR16), \r
+ NewScriptFile->CurrentCommand->Cl,\r
+ PrintBuffSize/sizeof(CHAR16) - 1\r
);\r
\r
+ SaveBufferList(&OldBufferList);\r
+\r
//\r
// NULL out comments\r
//\r
//\r
// Due to variability in starting the find and replace action we need to have both buffers the same.\r
//\r
- StrCpyS( CommandLine, \r
- PcdGet16(PcdShellPrintBufferSize)/sizeof(CHAR16), \r
- CommandLine2\r
+ StrnCpyS( CommandLine, \r
+ PrintBuffSize/sizeof(CHAR16), \r
+ CommandLine2,\r
+ PrintBuffSize/sizeof(CHAR16) - 1\r
);\r
\r
//\r
if (NewScriptFile->Argv != NULL) {\r
switch (NewScriptFile->Argc) {\r
default:\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%9", NewScriptFile->Argv[9], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%9", NewScriptFile->Argv[9], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 9:\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%8", NewScriptFile->Argv[8], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%8", NewScriptFile->Argv[8], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 8:\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%7", NewScriptFile->Argv[7], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%7", NewScriptFile->Argv[7], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 7:\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%6", NewScriptFile->Argv[6], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%6", NewScriptFile->Argv[6], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 6:\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%5", NewScriptFile->Argv[5], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%5", NewScriptFile->Argv[5], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 5:\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%4", NewScriptFile->Argv[4], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%4", NewScriptFile->Argv[4], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 4:\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%3", NewScriptFile->Argv[3], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%3", NewScriptFile->Argv[3], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 3:\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%2", NewScriptFile->Argv[2], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%2", NewScriptFile->Argv[2], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 2:\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%1", NewScriptFile->Argv[1], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%1", NewScriptFile->Argv[1], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 1:\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%0", NewScriptFile->Argv[0], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%0", NewScriptFile->Argv[0], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
break;\r
case 0:\r
break;\r
}\r
}\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%1", L"\"\"", FALSE, FALSE);\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%2", L"\"\"", FALSE, FALSE);\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%3", L"\"\"", FALSE, FALSE);\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%4", L"\"\"", FALSE, FALSE);\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%5", L"\"\"", FALSE, FALSE);\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%6", L"\"\"", FALSE, FALSE);\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%7", L"\"\"", FALSE, FALSE);\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%8", L"\"\"", FALSE, FALSE);\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%9", L"\"\"", FALSE, FALSE);\r
-\r
- StrCpyS( CommandLine2, \r
- PcdGet16(PcdShellPrintBufferSize)/sizeof(CHAR16), \r
- CommandLine\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%1", L"\"\"", FALSE, FALSE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%2", L"\"\"", FALSE, FALSE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%3", L"\"\"", FALSE, FALSE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%4", L"\"\"", FALSE, FALSE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%5", L"\"\"", FALSE, FALSE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%6", L"\"\"", FALSE, FALSE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%7", L"\"\"", FALSE, FALSE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%8", L"\"\"", FALSE, FALSE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%9", L"\"\"", FALSE, FALSE);\r
+\r
+ StrnCpyS( CommandLine2, \r
+ PrintBuffSize/sizeof(CHAR16), \r
+ CommandLine,\r
+ PrintBuffSize/sizeof(CHAR16) - 1\r
);\r
\r
LastCommand = NewScriptFile->CurrentCommand;\r
\r
ShellCommandRegisterExit(FALSE, 0);\r
Status = EFI_SUCCESS;\r
+ RestoreBufferList(&OldBufferList);\r
break;\r
}\r
if (ShellGetExecutionBreakFlag()) {\r
+ RestoreBufferList(&OldBufferList);\r
break;\r
}\r
if (EFI_ERROR(Status)) {\r
+ RestoreBufferList(&OldBufferList);\r
break;\r
}\r
if (ShellCommandGetExit()) {\r
+ RestoreBufferList(&OldBufferList);\r
break;\r
}\r
}\r
NewScriptFile->CurrentCommand->Reset = TRUE;\r
}\r
}\r
+ RestoreBufferList(&OldBufferList);\r
}\r
\r
\r
//\r
// get the argc and argv updated for scripts\r
//\r
- Status = UpdateArgcArgv(ParamProtocol, CmdLine, &Argv, &Argc);\r
+ Status = UpdateArgcArgv(ParamProtocol, CmdLine, Script_File_Name, &Argv, &Argc);\r
if (!EFI_ERROR(Status)) {\r
\r
if (Handle == NULL) {\r