Mercurial > octave
changeset 30267:535f97bb5f86
ls: Use "ls" command also on Windows if available.
* scripts/miscellaneous/ls_command.m: "file_in_path" doesn't take PATHEXT into
account. Use "where" command instead to check if "ls" executable is available
on MinGW. Adjust condition in BIST.
* scripts/miscellaneous/ls.m: Use argument "-1" if "ls" command is used.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Mon, 01 Nov 2021 14:37:01 +0100 |
parents | 38ee67b5ec9f |
children | 007dd7d008b3 |
files | scripts/miscellaneous/ls.m scripts/miscellaneous/ls_command.m |
diffstat | 2 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/ls.m Mon Nov 01 11:36:08 2021 +0900 +++ b/scripts/miscellaneous/ls.m Mon Nov 01 14:37:01 2021 +0100 @@ -85,11 +85,12 @@ args = ""; endif - if (nargout > 0 && (isunix () || ismac ())) + ls_cmd = ls_command (); + if (nargout > 0 && strncmp (ls_cmd, "ls", 2)) args = ["-1 ", args]; endif - cmd = [ls_command() " " args]; + cmd = [ls_cmd, " ", args]; if (page_screen_output () || nargout > 0) [status, output] = system (cmd);
--- a/scripts/miscellaneous/ls_command.m Mon Nov 01 11:36:08 2021 +0900 +++ b/scripts/miscellaneous/ls_command.m Mon Nov 01 14:37:01 2021 +0100 @@ -37,7 +37,7 @@ if (isempty (__ls_command__)) ## MinGW uses different ls_command if (ispc () && ! isunix () - && isempty (file_in_path (getenv ("PATH"), "ls"))) + && system ("where ls", true)) __ls_command__ = "dir /D"; else __ls_command__ = "ls -C"; @@ -64,7 +64,7 @@ %!test %! cmd = ls_command (); %! assert (ischar (cmd)); -%! if (ispc () && ! isunix ()) +%! if (ispc () && ! isunix () && system ("where ls", true)) %! assert (cmd(1:3), "dir"); %! else %! assert (cmd(1:2), "ls");