mirror of https://github.com/acidanthera/audk.git
ShellPkg: Update CWD and current mapping when commands return
Some commands may cause current directory or even current mapping become invalid. For example, "MAP" after unplugging the USB thumb key may cause current mapping "FS0:" disappear. This patch updates the CWD and current mapping when commands return. It also causes the command prompt change to default "Shell>". Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Huajing Li <huajing.li@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by Jaben Carsey <jaben.carsey@intel.com>
This commit is contained in:
parent
055fafe1ce
commit
f72df3568f
|
@ -2614,6 +2614,7 @@ RunShellCommand(
|
|||
CHAR16 *FirstParameter;
|
||||
CHAR16 *TempWalker;
|
||||
SHELL_OPERATION_TYPES Type;
|
||||
CONST CHAR16 *CurDir;
|
||||
|
||||
ASSERT(CmdLine != NULL);
|
||||
if (StrLen(CmdLine) == 0) {
|
||||
|
@ -2705,6 +2706,21 @@ RunShellCommand(
|
|||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
|
||||
SetLastError(SHELL_NOT_FOUND);
|
||||
}
|
||||
//
|
||||
// Check whether the current file system still exists. If not exist, we need update "cwd" and gShellCurMapping.
|
||||
//
|
||||
CurDir = EfiShellGetCurDir (NULL);
|
||||
if (CurDir != NULL) {
|
||||
if (EFI_ERROR(ShellFileExists (CurDir))) {
|
||||
//
|
||||
// EfiShellSetCurDir() cannot set current directory to NULL.
|
||||
// EfiShellSetEnv() is not allowed to set the "cwd" variable.
|
||||
// Only InternalEfiShellSetEnv () is allowed setting the "cwd" variable.
|
||||
//
|
||||
InternalEfiShellSetEnv (L"cwd", NULL, TRUE);
|
||||
gShellCurMapping = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL(CleanOriginal);
|
||||
SHELL_FREE_NON_NULL(FirstParameter);
|
||||
|
|
Loading…
Reference in New Issue