- } else {\r
- //\r
- // If this is a mapped drive change handle that...\r
- //\r
- if (CleanOriginal[(StrLen(CleanOriginal)-1)] == L':' && StrStr(CleanOriginal, L" ") == NULL) {\r
- Status = ChangeMappedDrive(CleanOriginal);\r
- SHELL_FREE_NON_NULL(CleanOriginal);\r
- return (Status);\r
- }\r
-\r
-\r
- ///@todo update this section to divide into 3 ways - run internal command, run split (above), and run an external file...\r
- /// We waste a lot of time doing processing like StdIn,StdOut,Argv,Argc for things that are external files...\r
-\r
-\r
-\r
- Status = UpdateStdInStdOutStdErr(ShellInfoObject.NewShellParametersProtocol, CleanOriginal, &OriginalStdIn, &OriginalStdOut, &OriginalStdErr, &OriginalSystemTableInfo);\r
- if (EFI_ERROR(Status)) {\r
- if (Status == EFI_NOT_FOUND) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_REDUNDA_REDIR), ShellInfoObject.HiiHandle);\r
- } else {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_REDIR), ShellInfoObject.HiiHandle);\r
- }\r
- } else {\r
- TrimSpaces(&CleanOriginal);\r
- \r
- //\r
- // get the argc and argv updated for internal commands\r
- //\r
- Status = UpdateArgcArgv(ShellInfoObject.NewShellParametersProtocol, CleanOriginal, &Argv, &Argc);\r
- ASSERT_EFI_ERROR(Status);\r
-\r
- if (StrStr(CleanOriginal, L"?") != NULL) {\r
- Status = DoHelpUpdateArgcArgv(\r
- &ShellInfoObject.NewShellParametersProtocol->Argc,\r
- &ShellInfoObject.NewShellParametersProtocol->Argv);\r
- }\r
-\r
- //\r
- // command or file?\r
- //\r
- if (ShellCommandIsCommandOnList(ShellInfoObject.NewShellParametersProtocol->Argv[0])) {\r
- //\r
- // Run the command (which was converted if it was an alias)\r
- //\r
- if (!EFI_ERROR(Status)) {\r
- Status = ShellCommandRunCommandHandler(ShellInfoObject.NewShellParametersProtocol->Argv[0], &ShellStatus, &LastError);\r
- ASSERT_EFI_ERROR(Status);\r
-\r
- if (sizeof(EFI_STATUS) == sizeof(UINT64)) {\r
- UnicodeSPrint(LeString, sizeof(LeString), L"0x%Lx", ShellStatus);\r
- } else {\r
- UnicodeSPrint(LeString, sizeof(LeString), L"0x%x", ShellStatus);\r
- }\r
- DEBUG_CODE(InternalEfiShellSetEnv(L"debuglasterror", LeString, TRUE););\r
- if (LastError) {\r
- InternalEfiShellSetEnv(L"lasterror", LeString, TRUE);\r
- }\r
- //\r
- // Pass thru the exitcode from the app.\r
- //\r
- if (ShellCommandGetExit()) {\r
- Status = ShellStatus;\r
- } else if (ShellStatus != 0 && IsScriptOnlyCommand(ShellInfoObject.NewShellParametersProtocol->Argv[0])) {\r
- Status = EFI_ABORTED;\r
- }\r
- }\r
- } else {\r
- //\r
- // run an external file (or script)\r
- //\r
- if (StrStr(ShellInfoObject.NewShellParametersProtocol->Argv[0], L":") != NULL) {\r
- ASSERT (CommandWithPath == NULL);\r
- if (ShellIsFile(ShellInfoObject.NewShellParametersProtocol->Argv[0]) == EFI_SUCCESS) {\r
- CommandWithPath = StrnCatGrow(&CommandWithPath, NULL, ShellInfoObject.NewShellParametersProtocol->Argv[0], 0);\r
- }\r
- }\r
- if (CommandWithPath == NULL) {\r
- CommandWithPath = ShellFindFilePathEx(ShellInfoObject.NewShellParametersProtocol->Argv[0], mExecutableExtensions);\r
- }\r
- if (CommandWithPath == NULL || ShellIsDirectory(CommandWithPath) == EFI_SUCCESS) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, ShellInfoObject.NewShellParametersProtocol->Argv[0]);\r
-\r
- if (sizeof(EFI_STATUS) == sizeof(UINT64)) {\r
- UnicodeSPrint(LeString, sizeof(LeString), L"0x%Lx", EFI_NOT_FOUND);\r
- } else {\r
- UnicodeSPrint(LeString, sizeof(LeString), L"0x%x", EFI_NOT_FOUND);\r
- }\r
- DEBUG_CODE(InternalEfiShellSetEnv(L"debuglasterror", LeString, TRUE););\r
- InternalEfiShellSetEnv(L"lasterror", LeString, TRUE);\r
- } else {\r
- //\r
- // Check if it's a NSH (script) file.\r
- //\r
- TempLocation = CommandWithPath+StrLen(CommandWithPath)-4;\r
- TempLocation2 = mScriptExtension;\r
- if ((StrLen(CommandWithPath) > 4) && (StringNoCaseCompare((VOID*)(&TempLocation), (VOID*)(&TempLocation2)) == 0)) {\r
- Status = RunScriptFile (CommandWithPath);\r
- } else {\r
- DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath(CommandWithPath);\r
- ASSERT(DevPath != NULL);\r
- Status = InternalShellExecuteDevicePath(\r
- &gImageHandle,\r
- DevPath,\r
- CleanOriginal,\r
- NULL,\r
- &StatusCode\r
- );\r