Mercurial > hg > octave-lojdl
changeset 14000:15400d5deb1c
ls.m: Fix handling of special characters in filename arguments (Bug #34950)
* ls.m: Escape special characters such as ["'(] in filename arguments.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 05 Dec 2011 17:13:35 -0800 |
parents | 1221086f1ba5 |
children | 5f0bb45e615c |
files | scripts/miscellaneous/ls.m |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/ls.m +++ b/scripts/miscellaneous/ls.m @@ -51,14 +51,17 @@ args = tilde_expand (varargin); if (nargin > 0) - ## FIXME -- this will fail for filenames that contain single quote - ## characters... - cmd = sprintf (" '%s'", args{:}); + if (ispc () && ! isunix ()) + ## shell (cmd.exe) on MinGW uses '^' as escape character + args = regexprep (args{:}, '([^\w.*?])', '^$1'); + else + args = regexprep (args{:}, '([^\w.*?])', '\$1'); + endif else - cmd = ""; + args = ""; endif - cmd = sprintf ("%s%s", __ls_command__, cmd); + cmd = sprintf ("%s %s", __ls_command__, args); if (page_screen_output () || nargout > 0)