summaryrefslogtreecommitdiff
path: root/ShellPkg/Application
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2015-10-23 02:03:20 +0000
committershenshushi <shenshushi@Edk2>2015-10-23 02:03:20 +0000
commitfbd2dfadfe6fb16ab7b49fca3764e05e65d97b8a (patch)
tree62be65e0eb87049beeb36b8ac95c2f127ce13c72 /ShellPkg/Application
parenta7e173b07a1ef336fc8d753cf85ae8473e92365a (diff)
downloadedk2-platforms-fbd2dfadfe6fb16ab7b49fca3764e05e65d97b8a.tar.xz
ShellPkg: Follow spec to remove the last '\' char in return name of GetCurDir().
In Shell spec 2.1 the return name of EFI_SHELL_PROTOCOL.GetCurDir() is defined as 'fs0:\current-dir' while in current implementation it's 'fs0:\current-dir\'. To follow spec the patch removed the redundant '\' char. Since it has been broken for a long time, some codes may depend on the broken behavior. After this change 'EFI_SHELL_PROTOCOL.GetCurDir()' and 'UefiShellLib.ShellGetCurrentDir()' will return a current directory string without tailing '\' (fs0:\current-dir), the value of Shell environment variable 'cwd' will become 'fs0:\current-dir' as well. This patch has updated all the code in EDKII to make them depend on the new behavior. Developers should check whether 'GetCurDir()' and 'ShellGetCurrentDir' are used in their source code. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18653 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Application')
-rw-r--r--ShellPkg/Application/Shell/FileHandleWrappers.c1
-rw-r--r--ShellPkg/Application/Shell/Shell.unibin4838 -> 4840 bytes
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.c18
3 files changed, 14 insertions, 5 deletions
diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c
index 91c35f7cb7..64f382718b 100644
--- a/ShellPkg/Application/Shell/FileHandleWrappers.c
+++ b/ShellPkg/Application/Shell/FileHandleWrappers.c
@@ -510,6 +510,7 @@ FileInterfaceStdInRead(
Cwd = ShellInfoObject.NewEfiShellProtocol->GetCurDir(NULL);
if (Cwd != NULL) {
StrnCpyS(TabStr, (*BufferSize)/sizeof(CHAR16), Cwd, (*BufferSize)/sizeof(CHAR16) - 1);
+ StrCatS(TabStr, (*BufferSize)/sizeof(CHAR16), L"\\");
if (TabStr[StrLen(TabStr)-1] == L'\\' && *(CurrentString + TabPos) == L'\\' ) {
TabStr[StrLen(TabStr)-1] = CHAR_NULL;
}
diff --git a/ShellPkg/Application/Shell/Shell.uni b/ShellPkg/Application/Shell/Shell.uni
index 04f001d387..25cf69966b 100644
--- a/ShellPkg/Application/Shell/Shell.uni
+++ b/ShellPkg/Application/Shell/Shell.uni
Binary files differ
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index 28521ecc15..3a963849f2 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -532,12 +532,13 @@ EfiShellGetDevicePathFromFilePath(
if (Cwd == NULL) {
return (NULL);
}
- Size = StrSize(Cwd) + StrSize(Path) - sizeof(CHAR16);
+ Size = StrSize(Cwd) + StrSize(Path);
NewPath = AllocateZeroPool(Size);
if (NewPath == NULL) {
return (NULL);
}
StrCpyS(NewPath, Size/sizeof(CHAR16), Cwd);
+ StrCatS(NewPath, Size/sizeof(CHAR16), L"\\");
if (*Path == L'\\') {
Path++;
while (PathRemoveLastItem(NewPath)) ;
@@ -2495,6 +2496,7 @@ EfiShellOpenFileList(
CurDir = EfiShellGetCurDir(NULL);
ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));
StrnCatGrow(&Path2, &Path2Size, CurDir, 0);
+ StrnCatGrow(&Path2, &Path2Size, L"\\", 0);
if (*Path == L'\\') {
Path++;
while (PathRemoveLastItem(Path2)) ;
@@ -2796,6 +2798,8 @@ EfiShellSetEnv(
FileSystemMapping is not NULL, it returns the current directory associated with the
FileSystemMapping. In both cases, the returned name includes the file system
mapping (i.e. fs0:\current-dir).
+
+ Note that the current directory string should exclude the tailing backslash character.
@param FileSystemMapping A pointer to the file system mapping. If NULL,
then the current working directory is returned.
@@ -2852,6 +2856,8 @@ EfiShellGetCurDir(
If the current working directory or the current working file system is changed then the
%cwd% environment variable will be updated
+ Note that the current directory string should exclude the tailing backslash character.
+
@param FileSystem A pointer to the file system's mapped name. If NULL, then the current working
directory is changed.
@param Dir Points to the NULL-terminated directory on the device specified by FileSystem.
@@ -2939,9 +2945,11 @@ EfiShellSetCurDir(
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
}
- if ((MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') || (MapListItem->CurrentDirectoryPath == NULL)) {
+ if ((MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] == L'\\') || (MapListItem->CurrentDirectoryPath == NULL)) {
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
- MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
+ if (MapListItem->CurrentDirectoryPath != NULL) {
+ MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] = CHAR_NULL;
+ }
}
} else {
//
@@ -2973,9 +2981,9 @@ EfiShellSetCurDir(
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
- if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') {
+ if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] == L'\\') {
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
- MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
+ MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] = CHAR_NULL;
}
}
}