Function to process a NSH script file. @param[in] ScriptPath Pointer to the script file name (including file system path). @param[in] Handle the handle of the script file already opened. @param[in] CmdLine the command line to run. @param[in] ParamProtocol the shell parameters protocol pointer @retval EFI_SUCCESS the script completed
| 3192 | @retval EFI_SUCCESS the script completed successfully |
| 3193 | **/ |
| 3194 | EFI_STATUS |
| 3195 | RunScriptFile ( |
| 3196 | IN CONST CHAR16 *ScriptPath, |
| 3197 | IN SHELL_FILE_HANDLE Handle OPTIONAL, |
| 3198 | IN CONST CHAR16 *CmdLine, |
| 3199 | IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol |
| 3200 | ) |
| 3201 | { |
| 3202 | EFI_STATUS Status; |
| 3203 | SHELL_FILE_HANDLE FileHandle; |
| 3204 | UINTN Argc; |
| 3205 | CHAR16 **Argv; |
| 3206 | |
| 3207 | if (ShellIsFile(ScriptPath) != EFI_SUCCESS) { |
| 3208 | return (EFI_INVALID_PARAMETER); |
| 3209 | } |
| 3210 | |
| 3211 | // |
| 3212 | // get the argc and argv updated for scripts |
| 3213 | // |
| 3214 | Status = UpdateArgcArgv(ParamProtocol, CmdLine, Script_File_Name, &Argv, &Argc); |
| 3215 | if (!EFI_ERROR(Status)) { |
| 3216 | |
| 3217 | if (Handle == NULL) { |
| 3218 | // |
| 3219 | // open the file |
| 3220 | // |
| 3221 | Status = ShellOpenFileByName(ScriptPath, &FileHandle, EFI_FILE_MODE_READ, 0); |
| 3222 | if (!EFI_ERROR(Status)) { |
| 3223 | // |
| 3224 | // run it |
| 3225 | // |
| 3226 | Status = RunScriptFileHandle(FileHandle, ScriptPath); |
| 3227 | |
| 3228 | // |
| 3229 | // now close the file |
| 3230 | // |
| 3231 | ShellCloseFile(&FileHandle); |
| 3232 | } |
| 3233 | } else { |
| 3234 | Status = RunScriptFileHandle(Handle, ScriptPath); |
| 3235 | } |
| 3236 | } |
| 3237 | |
| 3238 | // |
| 3239 | // This is guaranteed to be called after UpdateArgcArgv no matter what else happened. |
| 3240 | // This is safe even if the update API failed. In this case, it may be a no-op. |
| 3241 | // |
| 3242 | RestoreArgcArgv(ParamProtocol, &Argv, &Argc); |
| 3243 | |
| 3244 | return (Status); |
| 3245 | } |
| 3246 | |
| 3247 | /** |
| 3248 | Return the pointer to the first occurrence of any character from a list of characters. |
no test coverage detected