bugGNU Octave - Bugs: bug #30650, Feature Request: mkdir should...

 
 

bug #30650: Feature Request: mkdir should create hierarchy

Submitter:  forkandwait <forkandwait>
Submitted:  Wed 04 Aug 2010 06:42:17 PM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  1 - Later Item Group:  Feature Request
Status:  Fixed Assigned to:  lachlan
Originator Name:  forkandwait Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 14 May 2016 01:45:03 AM UTC, comment #14: 

I cleaned up the cset significantly and checked it in here (http://hg.savannah.gnu.org/hgweb/octave/rev/b8c05cc524ef).

Fixed, after only 5.5 years!

Rik <rik5>
Group administrator
Sun 01 May 2016 12:40:56 PM UTC, comment #13: 

The previous patch had a few bugs.  This version should be ready. (Famous last words...)

It has renamed the built-in to _mkdir_ so as not to conflict with the script.  A typo in the documentation has been fixed.  The script has been added to modules.mk.

(file #37036)

Lachlan Andrew <lachlan>
Wed 10 Feb 2016 03:39:22 AM UTC, comment #12: 

Carnë, the code you posted looks simple.  Why is it "definitely not an appropriate fix for Octave"?  Since this bug is over 5 years old, I think it would be better to have your kludge in than not have the functionality.

The attached changeset has a bit of a preamble to handle the case of a single parameter.  It is perhaps messy to have a script with the same name as a built-in, but that could easily be fixed by renaming the built-in.

(file #36286)

Lachlan Andrew <lachlan>
Fri 30 Nov 2012 07:43:47 AM UTC, comment #11: 

Upps. There was a mistake on the code I just posted:


function [status, msg, msgid] = mkdir (parent, dirname)
  if (! isdir (parent))
    [grandparent, name, ext]  = fileparts (parent);
    [status, msg, msgid] = mkdir (parent, dirname);
    if (! status)
      return
    endif
  endif
  [status, msg, msgid] = builtin ("mkdir", grandparent, [name ext]);
endfunction


Carnë Draug <carandraug>
Group Member
Fri 30 Nov 2012 07:40:08 AM UTC, comment #10: 

I just had this problem with kakila when working on pkg. The following can be a temporary fix for someone who stumbles upon this. It is definitely not an appropriate fix for Octave:


function [status, msg, msgid] = mkdir (parent, dirname)
  if (! isdir (parent))
    [grandparent, name, ext]  = fileparts (parent);
    [status, msg, msgid] = builtin ("mkdir", grandparent, [name ext]);
    if (! status)
      return
    endif
  endif
  [status, msg, msgid] = mkdir (parent, dirname);
endfunction


Carnë Draug <carandraug>
Group Member
Thu 07 Jun 2012 11:03:31 PM UTC, comment #9: 

I backed out two changesets related to this bug (see the following commits linked below) because there are some problems with using the gnulib mkdir-p module with MSVC and the problems that Rik noticed and (I failed to fix, see the patch that I attached to the bug report) are still not fixed.  So I think it would be better to wait until the gnulib problems are addressed and we understand how to use the mkdir-p module correctly to do exactly what mkdir does but for a directory tree instead of a single directory.  You'd think this would be a simple problem...

http://hg.savannah.gnu.org/hgweb/octave/rev/7e198fe3732c
http://hg.savannah.gnu.org/hgweb/octave/rev/0ab3dd0fad18

John W. Eaton <jwe>
Group administrator
Mon 28 May 2012 04:44:18 PM UTC, comment #8: 

The changing of pwd by mkdir stops the 'make check' target from working.  I have committed a very temporary fix here (http://hg.savannah.gnu.org/hgweb/octave/rev/c2411bff11c6) until 'mkdir -p' is sorted out.

Rik <rik5>
Group administrator
Thu 24 May 2012 06:36:42 PM UTC, comment #7: 

I reopened this report in response to Rik's comments.

I also tried fixing the problems, but I just don't understand how the gnulib mkdir-p thing is supposed to work, and I don't have time to work on this now.

I've attached my attempt below.  This seems to solve the umask problem in some cases, but not all.  With my changes, it fails for things like

 mkdir ("/tmp/foo/bar")

if only /tmp exists.

I recommend looking at the coreutils mkdir program to see how this gnulib module is supposed to be used.

Unfortunately, the gnulib code seems to be written with the idea that printing error messages is ok.  Or maybe there is some way to disable that with the gnulib error module that I don't know about.  We need to have Octave in control of printing error messages, not gnulib.


(file #25916)

John W. Eaton <jwe>
Group administrator
Thu 24 May 2012 01:31:26 AM UTC, comment #6: 

I just checked the new code and I found some incompatibilities between 3.6.1 and the development code.

Issue #1 : umask not respected

On Linux Kubuntu 10.04, the following code produces different results under 3.6.1 and the development tip.


umask (777);
mkdir tmp1


Under 3.6.1, 'ls -ld tmp1' shows
d---------
Under dev tip it shows
drwxrwxrwx

Issue #2 : pwd is changed by mkdir


pwd
ans = /home/rik/wip
mkdir ("~", "tmp1");
pwd
ans = /home/rik


This does not occur with 3.6.1.

Rik <rik5>
Group administrator
Wed 23 May 2012 08:39:58 PM UTC, comment #5: 

Ok I pushed a version that copies the data in the changeset

http://hg.savannah.gnu.org/hgweb/octave/rev/a543ed02e673

As for my question about the inclusion of mkdir-p.h, my ugly means of including the headers was a hangover from the fact that I initially didn't include these gnulib modules in bootstrap.conf. As the headers are copies to libgnu/ I don't need to include the path in the include statement

D.

David Bateman <dbateman>
Group Member
Wed 23 May 2012 07:02:01 PM UTC, comment #4: 

Looking at the current version of savewd_process_files, it seems that there should be const and non-const versions of this function, but this is C, so...

Your action functon won't write to the non-const string, but even so, I don't really like casting away const so I'd say make a copy.

John W. Eaton <jwe>
Group administrator
Wed 23 May 2012 11:24:11 AM UTC, comment #3: 

I propose the attached changeset. However there are two things I don't like about 1

1) The manner in which mkdir-p.h and savewd.h are included in lo-cutils.c. What is the recommended manner to do this?
2) in octave_mkdir_parents the argument "dir" drops the const qualifier when being assigned to argv[0]. Should I make a copy instead?

Any particular recommendations or should I commit this changeset as is?

D.

(file #25910)

David Bateman <dbateman>
Group Member
Sun 29 Aug 2010 02:36:54 PM UTC, comment #2: 

Using the gnulib mkdir_p module seems like a good solution.  It would be helpful if someone would prepare a changeset to add this feature.

John W. Eaton <jwe>
Group administrator
Wed 04 Aug 2010 10:44:42 PM UTC, comment #1: 

Making this change would make Octave more Matlab compatible as the Matlab function already attempts to create directories which don't exist.  See the remarks section of

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/mkdir.html

Realistically, it shouldn't be that difficult to implement.  Octave pulls the mkdir function from gnulib for portability reasons.  Gnulib already has a mkdir module which implements 'mkdir -p' and creates the necessary intervening directories.  See a description of the module at:

http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=modules/mkdir-p



Rik <rik5>
Group administrator
Wed 04 Aug 2010 06:42:17 PM UTC, original submission:  

Currently mkdir fails if given intermediate directories such that it would be necessary to create a hierarchy.  This is NOT conformable to M*, and it would be useful to have this feature (see below for a discussion).  JWE has also said he would consider a patch.

http://octave.1599824.n4.nabble.com/recursive-mkdir-DIR-s-mylib-mkdir-DIR-s-td1629148.html

forkandwait <forkandwait>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #37036:  bug_30650_v2.cset added by lachlan (6KiB - text/x-diff)
file #36286:  bug_30650.cset added by lachlan (3KiB - application/octet-stream)
file #25916:  mkdir-p-diffs.txt added by jwe (4KiB - text/plain)
file #25910:  changeset added by dbateman (5KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lachlan (Updated the item)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by carandraug (Posted a comment)
  • -email is unavailable- added by dbateman (Updated the item)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by forkandwait (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 19 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-05-14 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2016-05-01 lachlan Attached File- Added bug_30650_v2.cset, #37036
        StatusPostponed Patch Submitted
        Assigned todbateman lachlan
        Release3.2.4 dev
    2016-02-10 lachlan Attached File- Added bug_30650.cset, #36286
    2014-01-19 mtmiller CategoryNone Octave Function
        Operating SystemMicrosoft Windows Any
    2012-05-24 jwe Attached File- Added mkdir-p-diffs.txt, #25916
        StatusFixed Postponed
        Open/ClosedClosed Open
    2012-05-23 dbateman StatusNone Fixed
        Assigned toNone dbateman
        Open/ClosedOpen Closed
    2012-05-23 dbateman Attached File- Added changeset, #25910
    2010-09-16 jwe Priority5 - Normal 1 - Later
    2010-08-04 rik5 Severity3 - Normal 1 - Wish
        Summarymkdir should create hierarchy Feature Request: mkdir should create hierarchy

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code