Function to run the command or file. @param[in] Type the type of operation being run. @param[in] CmdLine the command line to run. @param[in] FirstParameter the first parameter on the command line @param[in] ParamProtocol the shell parameters protocol pointer @param[out] CommandStatus the status from the command line. @retval EFI_SUCCESS The com
| 2478 | @retval EFI_ABORTED The command's operation was aborted. |
| 2479 | **/ |
| 2480 | EFI_STATUS |
| 2481 | RunCommandOrFile( |
| 2482 | IN SHELL_OPERATION_TYPES Type, |
| 2483 | IN CONST CHAR16 *CmdLine, |
| 2484 | IN CHAR16 *FirstParameter, |
| 2485 | IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol, |
| 2486 | OUT EFI_STATUS *CommandStatus |
| 2487 | ) |
| 2488 | { |
| 2489 | EFI_STATUS Status; |
| 2490 | EFI_STATUS StartStatus; |
| 2491 | CHAR16 *CommandWithPath; |
| 2492 | EFI_DEVICE_PATH_PROTOCOL *DevPath; |
| 2493 | SHELL_STATUS CalleeExitStatus; |
| 2494 | |
| 2495 | Status = EFI_SUCCESS; |
| 2496 | CommandWithPath = NULL; |
| 2497 | DevPath = NULL; |
| 2498 | CalleeExitStatus = SHELL_INVALID_PARAMETER; |
| 2499 | |
| 2500 | switch (Type) { |
| 2501 | case Internal_Command: |
| 2502 | Status = RunInternalCommand(CmdLine, FirstParameter, ParamProtocol, CommandStatus); |
| 2503 | break; |
| 2504 | case Script_File_Name: |
| 2505 | case Efi_Application: |
| 2506 | // |
| 2507 | // Process a fully qualified path |
| 2508 | // |
| 2509 | if (StrStr(FirstParameter, L":") != NULL) { |
| 2510 | // ASSERT (CommandWithPath == NULL); |
| 2511 | if (ShellIsFile(FirstParameter) == EFI_SUCCESS) { |
| 2512 | CommandWithPath = StrnCatGrow(&CommandWithPath, NULL, FirstParameter, 0); |
| 2513 | } |
| 2514 | } |
| 2515 | |
| 2516 | // |
| 2517 | // Process a relative path and also check in the path environment variable |
| 2518 | // |
| 2519 | if (CommandWithPath == NULL) { |
| 2520 | CommandWithPath = ShellFindFilePathEx(FirstParameter, mExecutableExtensions); |
| 2521 | } |
| 2522 | |
| 2523 | // |
| 2524 | // This should be impossible now. |
| 2525 | // |
| 2526 | // ASSERT(CommandWithPath != NULL); |
| 2527 | |
| 2528 | // |
| 2529 | // Make sure that path is not just a directory (or not found) |
| 2530 | // |
| 2531 | if (!EFI_ERROR(ShellIsDirectory(CommandWithPath))) { |
| 2532 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter); |
| 2533 | SetLastError(SHELL_NOT_FOUND); |
| 2534 | } |
| 2535 | switch (Type) { |
| 2536 | case Script_File_Name: |
| 2537 | Status = RunScriptFile (CommandWithPath, NULL, CmdLine, ParamProtocol); |
no test coverage detected