bugGNU Octave - Bugs: bug #56700, unzip with one argument does not...

 
 

bug #56700: unzip with one argument does not unzip to the current working directory

Submitter:  Guillaume <gyom>
Submitted:  Wed 31 Jul 2019 12:22:23 PM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 06 Aug 2019 03:19:34 AM UTC, comment #4: 

I made Octave compatible with Matlab in this changeset https://hg.savannah.gnu.org/hgweb/octave/rev/a6907d46464f.  This was on the development branch that will become Octave 6.1.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Wed 31 Jul 2019 07:19:49 PM UTC, comment #3: 

The Matlab documentation for gunzip (https://www.mathworks.com/help/matlab/ref/gunzip.html) says


gunzip(gzipfilenames) extracts the archived contents of each file in gzipfilenames to the folder containing gzipfilenames


so it is possible that this is why we didn't do this earlier.  Matlab has one convention for untar, unzip and another convention for gunzip which seems rather stupid.

Rik <rik5>
Group administrator
Wed 31 Jul 2019 07:15:42 PM UTC, comment #2: 

I can confirm Mike's comment #1 that the unpacking of the zip file is done in the remote director, rather than the current directory, if none is specified.  The help text is explicit about this


     If DIR is specified the files are unpacked in this directory rather
     than the one where ZIPFILE is located.


On the other hand, Matlab's documentation (https://www.mathworks.com/help/matlab/ref/unzip.html) is also explicit about what it does


unzip(zipfilename) extracts the archived contents of zipfilename into the current folder


The code in question was introduced in to unzip.m by me in 2014 in cset a4e993343e93.


19258: function filelist = unzip (zipfile, dir = [])
 5808:
19258:   if (nargin < 1 || nargin > 2)
 6081:     print_usage ();
 5808:   endif
 5808:
19258:   if (isempty (dir))
19258:     dir = fileparts (zipfile);
19258:   endif


It's simple enough to change this to


   if (isempty (dir))
     dir = pwd ();
   endif


which I verified does what Matlab does.

I don't care much either way, but if we want to go for Matlab compatibility then it would be helpful if someone could review all of the pack/unpack files for campatibility.  For example, gunzip and untar are also Matlab functions which do roughly the same thing.

Rik <rik5>
Group administrator
Wed 31 Jul 2019 06:54:47 PM UTC, comment #1: 

This looks to me like a symptom of a larger class: unzip with one argument does not unzip contents to the current working directory, but to the parent directory of the zip file. Doesn't matter if that's a URL or a local file name.

The following


unzip ("/home/user/foo.zip")


extracts the contents of the zip file into /home/user, not into the current working directory. And the following


unzip ("/usr/lib/jvm/default-java/lib/src.zip")


fails with a permission denied error. But


unzip ("/usr/lib/jvm/default-java/lib/src.zip", pwd)


works as expected.

Mike Miller <mtmiller>
Group Member
Wed 31 Jul 2019 12:22:23 PM UTC, original submission:  

When using unzip with an URL without specifying the output directory, the URL is mistakenly used to define it:


unzip ('http://hg.savannah.gnu.org/hgweb/mkdoc/archive/tip.zip');


It works as expected with:


unzip ('http://hg.savannah.gnu.org/hgweb/mkdoc/archive/tip.zip', pwd);
% or
unpack ('http://hg.savannah.gnu.org/hgweb/mkdoc/archive/tip.zip')


Guillaume <gyom>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by gyom (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-08-06 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2019-07-31 mtmiller Severity3 - Normal 2 - Minor
        StatusNone Confirmed
        SummaryUnzip from URL unzip with one argument does not unzip to the current working directory

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code