[edk2] [PATCH] ShellPkg/Ls: Handle path specified from root

Jeff Westfahl posted 1 patch 6 years, 11 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[edk2] [PATCH] ShellPkg/Ls: Handle path specified from root
Posted by Jeff Westfahl 6 years, 11 months ago
This fixes 'ls' when specifying a path from the root, like "ls \" from
within a subfolder. Currently, 'ls' will append the specified path to the
current working directory. The correct behavior is to start from the root
of the currently selected filesystem.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
---
 ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
index 52ae18f..b14bbcd 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
@@ -679,7 +679,7 @@ ShellCommandRunLs (
             // We got a valid fully qualified path or we have a CWD
             //
             ASSERT((FullPath == NULL && Size == 0) || (FullPath != NULL));
-            if (StrStr(PathName, L":") == NULL) {
+            if (PathName [0] != L'\\' && StrStr(PathName, L":") == NULL) {
               StrnCatGrow(&FullPath, &Size, gEfiShellProtocol->GetCurDir(NULL), 0);
               if (FullPath == NULL) {
                 ShellCommandLineFreeVarList (Package);
-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] ShellPkg/Ls: Handle path specified from root
Posted by Jeff Westfahl 6 years, 11 months ago
Hmm, this one still has a bug. The correct folder is listed, but it prints 
the wrong folder name before listing the contents. I'll fix that and post 
again.

Jeff

On Fri, 12 May 2017, Jeff Westfahl wrote:

> This fixes 'ls' when specifying a path from the root, like "ls \" from
> within a subfolder. Currently, 'ls' will append the specified path to the
> current working directory. The correct behavior is to start from the root
> of the currently selected filesystem.
>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
> ---
> ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> index 52ae18f..b14bbcd 100644
> --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
> @@ -679,7 +679,7 @@ ShellCommandRunLs (
>             // We got a valid fully qualified path or we have a CWD
>             //
>             ASSERT((FullPath == NULL && Size == 0) || (FullPath != NULL));
> -            if (StrStr(PathName, L":") == NULL) {
> +            if (PathName [0] != L'\\' && StrStr(PathName, L":") == NULL) {
>               StrnCatGrow(&FullPath, &Size, gEfiShellProtocol->GetCurDir(NULL), 0);
>               if (FullPath == NULL) {
>                 ShellCommandLineFreeVarList (Package);
> -- 
> 2.7.4
>
>
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel