MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / RunShellCommand

Function RunShellCommand

ShellPkg/Application/Shell/Shell.c:2671–2781  ·  view source on GitHub ↗

Function will process and run a command line. This will determine if the command line represents an internal shell command or dispatch an external application. @param[in] CmdLine The command line to parse. @param[out] CommandStatus The status from the command line. @retval EFI_SUCCESS The command was completed. @retval EFI_ABORTED The command's operation was

Source from the content-addressed store, hash-verified

2669 @retval EFI_ABORTED The command's operation was aborted.
2670**/
2671EFI_STATUS
2672RunShellCommand(
2673 IN CONST CHAR16 *CmdLine,
2674 OUT EFI_STATUS *CommandStatus
2675 )
2676{
2677 EFI_STATUS Status;
2678 CHAR16 *CleanOriginal;
2679 CHAR16 *FirstParameter;
2680 CHAR16 *TempWalker;
2681 SHELL_OPERATION_TYPES Type;
2682
2683// ASSERT(CmdLine != NULL);
2684 if (!CmdLine) {
2685 return (EFI_SUCCESS);
2686 }
2687 if (StrLen(CmdLine) == 0) {
2688 return (EFI_SUCCESS);
2689 }
2690
2691 Status = EFI_SUCCESS;
2692 CleanOriginal = NULL;
2693
2694 CleanOriginal = StrnCatGrow(&CleanOriginal, NULL, CmdLine, 0);
2695 if (CleanOriginal == NULL) {
2696 return (EFI_OUT_OF_RESOURCES);
2697 }
2698
2699 TrimSpaces(&CleanOriginal);
2700
2701 //
2702 // NULL out comments (leveraged from RunScriptFileHandle() ).
2703 // The # character on a line is used to denote that all characters on the same line
2704 // and to the right of the # are to be ignored by the shell.
2705 // Afterwards, again remove spaces, in case any were between the last command-parameter and '#'.
2706 //
2707 for (TempWalker = CleanOriginal; TempWalker != NULL && *TempWalker != CHAR_NULL; TempWalker++) {
2708 if (*TempWalker == L'^') {
2709 if (*(TempWalker + 1) == L'#') {
2710 TempWalker++;
2711 }
2712 } else if (*TempWalker == L'#') {
2713 *TempWalker = CHAR_NULL;
2714 }
2715 }
2716
2717 TrimSpaces(&CleanOriginal);
2718
2719 //
2720 // Handle case that passed in command line is just 1 or more " " characters.
2721 //
2722 if (StrLen (CleanOriginal) == 0) {
2723 SHELL_FREE_NON_NULL(CleanOriginal);
2724 return (EFI_SUCCESS);
2725 }
2726
2727 Status = ProcessCommandLineToFinal(&CleanOriginal);
2728 if (EFI_ERROR(Status)) {

Callers 3

DoStartupScriptFunction · 0.85
RunCommandFunction · 0.85
InternalShellExecuteFunction · 0.85

Calls 13

TrimSpacesFunction · 0.85
ContainsSplitFunction · 0.85
GetNextParameterFunction · 0.85
GetOperationTypeFunction · 0.85
ChangeMappedDriveFunction · 0.85
SetupAndRunCommandOrFileFunction · 0.85
ShellPrintHiiExFunction · 0.85
SetLastErrorFunction · 0.85
StrLenFunction · 0.50
AllocateZeroPoolFunction · 0.50

Tested by

no test coverage detected