# HG changeset patch # User Rik # Date 1435785289 25200 # Node ID 2fc43288a6c48b8c02fa1ddcaf1d82249408dc7c # Parent 077e73619ba8ab2189450402ac5d7616b0f3c4f1 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. diff -r 077e73619ba8 -r 2fc43288a6c4 scripts/miscellaneous/unpack.m --- a/scripts/miscellaneous/unpack.m Wed Jun 24 14:37:55 2015 -0400 +++ b/scripts/miscellaneous/unpack.m Wed Jul 01 14:14:49 2015 -0700 @@ -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;