Mercurial > hg > octave-nkf
changeset 20501:2fc43288a6c4 stable
unpack.m: Stop hang when unpacking on to existing filename (bug #45331).
* unpack.m: Follow documentation and use current directory for unpacking if no
output directory is specified. Call tilde_expand() on any user-supplied
directory in case it contains '~'. Add -f(orce) flag to gzip and bzip unpack
commands so that any file will be overwritten and Octave will not hang waiting
for user input. Strip trailing file separator from output directory so that
a proper comparison is made to beginning directory which never includes the
file separator.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 01 Jul 2015 14:14:49 -0700 |
parents | 077e73619ba8 |
children | 3300cb76cccd |
files | scripts/miscellaneous/unpack.m |
diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/unpack.m +++ b/scripts/miscellaneous/unpack.m @@ -146,6 +146,12 @@ file = make_absolute_filename (file); + if (isempty (dir)) + dir = "."; + else + dir = tilde_expand (dir); + endif + ## Instructions on what to do for any extension. ## ## The field names are the file extension without periods. @@ -157,12 +163,12 @@ ## bzip2 and gzip decompress the file at its location). persistent commandlist; if (isempty (commandlist)) - commandlist.gz = {'gzip -d -v -r "%s"', ... - 'gzip -d -r "%s"', ... + commandlist.gz = {'gzip -d -v -f -r "%s"', ... + 'gzip -d -f -r "%s"', ... @__parse_gzip__, true}; commandlist.z = commandlist.gz; - commandlist.bz2 = {'bzip2 -d -v "%s"', ... - 'bzip2 -d "%s"', ... + commandlist.bz2 = {'bzip2 -d -v -f "%s"', ... + 'bzip2 -d -f "%s"', ... @__parse_bzip2__, true}; commandlist.bz = commandlist.bz2; commandlist.tar = {'tar xvf "%s"', ... @@ -205,6 +211,9 @@ endif cstartdir = make_absolute_filename (startdir); cenddir = make_absolute_filename (dir); + if (cenddir(end) == filesep) + cenddir(end) = []; + endif needmove = move && ! strcmp (cstartdir, cenddir); if (nargout > 0 || needmove) command = commandv;