# HG changeset patch # User Rik # Date 1323726755 28800 # Node ID 29e9eb59f9174ebdcfd143e65f692169849be53b # Parent a8952515415d03392d00be30600f6f1f23b615f0 ls_command.m: Fix incorrect listing command on MinGW (Bug #35038, Bug #35039) * ls_command.m: Use 'dir /D' for listing command on MinGW. Add %! tests. diff --git a/scripts/miscellaneous/ls_command.m b/scripts/miscellaneous/ls_command.m --- a/scripts/miscellaneous/ls_command.m +++ b/scripts/miscellaneous/ls_command.m @@ -30,10 +30,10 @@ global __ls_command__; if (isempty (__ls_command__)) - ## FIXME -- ispc and isunix both return true for Cygwin. Should they? + ## MinGW uses different ls_command if (ispc () && ! isunix () && isempty (file_in_path (getenv ("PATH"), "ls"))) - __ls_command__ = "cmd /C dir /D"; + __ls_command__ = "dir /D"; else __ls_command__ = "ls -C"; endif @@ -54,3 +54,14 @@ endif endfunction + + +%!test +%! cmd = ls_command (); +%! assert (ischar (cmd)); +%! if (ispc () && ! isunix ()) +%! assert (cmd(1:3), "dir"); +%! else +%! assert (cmd(1:2), "ls"); +%! endif +