summaryrefslogtreecommitdiff
path: root/ShellPkg/Application
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2015-12-18 07:30:21 +0000
committervanjeff <vanjeff@Edk2>2015-12-18 07:30:21 +0000
commit631a25f3618b25a8a0bdd70d7338ce80a1f9c57d (patch)
tree325a5a87f6d7fd5c7b80aba2e769d19b442fe4ea /ShellPkg/Application
parent90fb9ed5a0d24117a4847b5d25bca84d8d90c5c2 (diff)
downloadedk2-platforms-631a25f3618b25a8a0bdd70d7338ce80a1f9c57d.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. (Sync patch r18653 from main trunk.) 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/branches/UDK2015@19395 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;
}
}
}