# HG changeset patch # User Rik # Date 1458681935 25200 # Node ID 50255c612915c7d937cc03e0810b5acf31c174d7 # Parent aac8b2ca928084b45d69328581124ee038be29ce Fix zip, gzip, bzip2 to allow names with spaces (bug #47232). * zip.m: Expand out wildcards with glob(), escape double quotes with regexprep, and then wrap file names in double quotes before passing to zip command via the shell. * __xzip__.m: Wrap file names in double quotes before passing through shell. diff -r aac8b2ca9280 -r 50255c612915 scripts/miscellaneous/private/__xzip__.m --- a/scripts/miscellaneous/private/__xzip__.m Sat Mar 19 14:29:55 2016 -0400 +++ b/scripts/miscellaneous/private/__xzip__.m Tue Mar 22 14:25:35 2016 -0700 @@ -70,7 +70,7 @@ cd (outdir); - cmd = sprintf (commandtemplate, sprintf (" %s", fnames{:})); + cmd = sprintf (commandtemplate, sprintf (' "%s"', fnames{:})); [status, output] = system (cmd); if (status) diff -r aac8b2ca9280 -r 50255c612915 scripts/miscellaneous/zip.m --- a/scripts/miscellaneous/zip.m Sat Mar 19 14:29:55 2016 -0400 +++ b/scripts/miscellaneous/zip.m Tue Mar 22 14:25:35 2016 -0700 @@ -55,7 +55,11 @@ zipfile = make_absolute_filename (zipfile); - cmd = sprintf ("zip -r %s %s", zipfile, sprintf (" %s", files{:})); + files = glob (files); # expand wildcards + files = regexprep (files, '"', '\\"'); # escape double quotes + files = sprintf (' "%s"', files{:}); # convert to space separated list + zipfile = regexprep (zipfile, '"', '\\"'); # escape double quotes + cmd = sprintf ('zip -r "%s" %s', zipfile, files); origdir = pwd (); cd (rootdir);