# HG changeset patch # User Rik # Date 1389136547 28800 # Node ID 3d22b24863b966ad38e55c2b858dc07e9f1a354b # Parent c0f036b5e292dd46e842b412155e0145e7ba7f43 ls.m: Enclose paths with spaces in double quotes on Windows (bug #40989). * ls.m: Only enclose paths in double quotes on Windows systems. Remove now redundant check for '/' at end of filename. For UNIX systems, pass special characters '[]' through to shell. diff -r c0f036b5e292 -r 3d22b24863b9 scripts/miscellaneous/ls.m --- a/scripts/miscellaneous/ls.m Thu Jan 02 10:12:36 2014 -0500 +++ b/scripts/miscellaneous/ls.m Tue Jan 07 15:15:47 2014 -0800 @@ -60,24 +60,15 @@ if (nargin > 0) args = tilde_expand (varargin); - is_dos = (ispc () && ! isunix ()); - if (is_dos) - optsep = "/"; + if (ispc () && ! isunix ()) + idx = ! strncmp (args, '/', 1); + ## Enclose paths, potentially having spaces, in double quotes: + args(idx) = strcat ('"', args(idx), '"'); + ## shell (cmd.exe) on MinGW uses '^' as escape character + args = regexprep (args, '([^\w.*?])', '^$1'); 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. - if (args{end}(end) == '/') - args{end}(end) = ""; - endif - else - args = regexprep (args, '([^\w.*? -])', '\\$1'); + ## Escape any special characters in filename + args = regexprep (args, '([^\w.*?-[]])', '\\$1'); endif args = sprintf ("%s ", args{:}); else