# HG changeset patch # User Felipe G. Nievinski # Date 1387975602 7200 # Node ID 05a53cc522b75fdaf590b866554556a9dc317a3c # Parent 8d332da6694fb32645018e21f22b2deb58c9fe00 fix ls when spaces are present in path (bug #40989) diff -r 8d332da6694f -r 05a53cc522b7 scripts/miscellaneous/ls.m --- a/scripts/miscellaneous/ls.m Tue Dec 24 01:42:04 2013 -0500 +++ b/scripts/miscellaneous/ls.m Wed Dec 25 10:46:42 2013 -0200 @@ -60,7 +60,16 @@ if (nargin > 0) args = tilde_expand (varargin); - if (ispc () && ! isunix ()) + is_dos = (ispc () && ! isunix ()); + if is_dos + optsep = "/"; + else + optsep = "-"; + endif + idx = ! strncmp (args, optsep, 1); + ## Enclose paths, potentially having spaces, in double quotes: + args(idx) = strcat ("\"", args(idx), "\""); + if is_dos ## shell (cmd.exe) on MinGW uses '^' as escape character args = regexprep (args, '([^\w.*? -])', '^$1'); ## Strip UNIX directory character which looks like an option to dir cmd.