Run an internal shell command. This API will update the shell's environment since these commands are libraries. @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_SUC
| 2366 | @retval EFI_ABORTED The command's operation was aborted. |
| 2367 | **/ |
| 2368 | EFI_STATUS |
| 2369 | RunInternalCommand( |
| 2370 | IN CONST CHAR16 *CmdLine, |
| 2371 | IN CHAR16 *FirstParameter, |
| 2372 | IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol, |
| 2373 | OUT EFI_STATUS *CommandStatus |
| 2374 | ) |
| 2375 | { |
| 2376 | EFI_STATUS Status; |
| 2377 | UINTN Argc; |
| 2378 | CHAR16 **Argv; |
| 2379 | SHELL_STATUS CommandReturnedStatus; |
| 2380 | BOOLEAN LastError; |
| 2381 | CHAR16 *Walker; |
| 2382 | CHAR16 *NewCmdLine; |
| 2383 | |
| 2384 | NewCmdLine = AllocateCopyPool (StrSize (CmdLine), CmdLine); |
| 2385 | if (NewCmdLine == NULL) { |
| 2386 | return EFI_OUT_OF_RESOURCES; |
| 2387 | } |
| 2388 | |
| 2389 | for (Walker = NewCmdLine; Walker != NULL && *Walker != CHAR_NULL ; Walker++) { |
| 2390 | if (*Walker == L'^' && *(Walker+1) == L'#') { |
| 2391 | CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0])); |
| 2392 | } |
| 2393 | } |
| 2394 | |
| 2395 | // |
| 2396 | // get the argc and argv updated for internal commands |
| 2397 | // |
| 2398 | Status = UpdateArgcArgv(ParamProtocol, NewCmdLine, Internal_Command, &Argv, &Argc); |
| 2399 | if (!EFI_ERROR(Status)) { |
| 2400 | // |
| 2401 | // Run the internal command. |
| 2402 | // |
| 2403 | Status = ShellCommandRunCommandHandler(FirstParameter, &CommandReturnedStatus, &LastError); |
| 2404 | |
| 2405 | if (!EFI_ERROR(Status)) { |
| 2406 | if (CommandStatus != NULL) { |
| 2407 | if (CommandReturnedStatus != SHELL_SUCCESS) { |
| 2408 | *CommandStatus = (EFI_STATUS)(CommandReturnedStatus | MAX_BIT); |
| 2409 | } else { |
| 2410 | *CommandStatus = EFI_SUCCESS; |
| 2411 | } |
| 2412 | } |
| 2413 | |
| 2414 | // |
| 2415 | // Update last error status. |
| 2416 | // some commands do not update last error. |
| 2417 | // |
| 2418 | if (LastError) { |
| 2419 | SetLastError(CommandReturnedStatus); |
| 2420 | } |
| 2421 | |
| 2422 | // |
| 2423 | // Pass thru the exitcode from the app. |
| 2424 | // |
| 2425 | if (ShellCommandGetExit()) { |
no test coverage detected