// If we got a file, run it\r
//\r
if (!EFI_ERROR(Status) && FileHandle != NULL) {\r
- Status = RunScriptFileHandle (FileHandle, mStartupScript);\r
+ Status = RunScriptFile (mStartupScript, FileHandle, L"", ShellInfoObject.NewShellParametersProtocol);\r
ShellInfoObject.NewEfiShellProtocol->CloseFile(FileHandle);\r
} else {\r
FileStringPath = ShellFindFilePath(mStartupScript);\r
Status = EFI_SUCCESS;\r
ASSERT(FileHandle == NULL);\r
} else {\r
- Status = RunScriptFile(FileStringPath);\r
+ Status = RunScriptFile(FileStringPath, NULL, L"", ShellInfoObject.NewShellParametersProtocol);\r
FreePool(FileStringPath);\r
}\r
}\r
}\r
switch (Type) {\r
case Script_File_Name:\r
- Status = RunScriptFile (CommandWithPath);\r
+ Status = RunScriptFile (CommandWithPath, NULL, CmdLine, ParamProtocol);\r
break;\r
case Efi_Application:\r
//\r
Function to process a NSH script file.\r
\r
@param[in] ScriptPath Pointer to the script file name (including file system path).\r
+ @param[in] Handle the handle of the script file already opened.\r
+ @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
**/\r
EFI_STATUS\r
EFIAPI\r
RunScriptFile (\r
- IN CONST CHAR16 *ScriptPath\r
+ IN CONST CHAR16 *ScriptPath,\r
+ IN SHELL_FILE_HANDLE Handle OPTIONAL,\r
+ IN CONST CHAR16 *CmdLine,\r
+ IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol\r
)\r
{\r
EFI_STATUS Status;\r
SHELL_FILE_HANDLE FileHandle;\r
+ UINTN Argc;\r
+ CHAR16 **Argv;\r
\r
if (ShellIsFile(ScriptPath) != EFI_SUCCESS) {\r
return (EFI_INVALID_PARAMETER);\r
}\r
\r
- Status = ShellOpenFileByName(ScriptPath, &FileHandle, EFI_FILE_MODE_READ, 0);\r
- if (EFI_ERROR(Status)) {\r
- return (Status);\r
- }\r
+ //\r
+ // get the argc and argv updated for scripts\r
+ //\r
+ Status = UpdateArgcArgv(ParamProtocol, CmdLine, &Argv, &Argc);\r
+ if (!EFI_ERROR(Status)) {\r
\r
- Status = RunScriptFileHandle(FileHandle, ScriptPath);\r
+ if (Handle == NULL) {\r
+ //\r
+ // open the file\r
+ //\r
+ Status = ShellOpenFileByName(ScriptPath, &FileHandle, EFI_FILE_MODE_READ, 0);\r
+ if (!EFI_ERROR(Status)) {\r
+ //\r
+ // run it\r
+ //\r
+ Status = RunScriptFileHandle(FileHandle, ScriptPath);\r
\r
- ShellCloseFile(&FileHandle);\r
+ //\r
+ // now close the file\r
+ //\r
+ ShellCloseFile(&FileHandle);\r
+ }\r
+ } else {\r
+ Status = RunScriptFileHandle(Handle, ScriptPath);\r
+ }\r
+ }\r
+\r
+ //\r
+ // This is guarenteed 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
return (Status);\r
}\r