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

 
 

bug #30650: Feature Request: mkdir should create hierarchy

Submitted by:  forkandwait <forkandwait>
Submitted on:  Wed 04 Aug 2010 06:42:17 PM UTC  
 
Category: Octave FunctionSeverity: 1 - Wish
Priority: 1 - LaterItem Group: Feature Request
Status: FixedAssigned to: Lachlan Andrew <lachlan>
Originator Name: forkandwaitOpen/Closed: Closed
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission 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>
Project 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>
Project MemberIn charge of this item.
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>
Project MemberIn charge of this item.
Fri 30 Nov 2012 07:43:47 AM UTC, comment #11:

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

Carnë Draug <carandraug>
Project 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:

Carnë Draug <carandraug>
Project 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>
Project 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>
Project 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>
Project 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.

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

Issue #2 : pwd is changed by mkdir

This does not occur with 3.6.1.

Rik <rik5>
Project 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>
Project 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>
Project 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>
Project 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>
Project 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>
Project 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 File(s):
   
   
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
  • -unavailable- added by lachlan (Updated the item)
  • -unavailable- added by mtmiller (Updated the item)
  • -unavailable- added by carandraug (Posted a comment)
  • -unavailable- added by dbateman (Updated the item)
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by forkandwait (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 19 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 14 May 2016 01:45:03 AM UTCrik5StatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Sun 01 May 2016 12:40:56 PM UTClachlanAttached File-=>Added bug_30650_v2.cset, #37036
      StatusPostponed=>Patch Submitted
      Assigned todbateman=>lachlan
      Release3.2.4=>dev
    Wed 10 Feb 2016 03:39:22 AM UTClachlanAttached File-=>Added bug_30650.cset, #36286
    Sun 19 Jan 2014 11:58:47 PM UTCmtmillerCategoryNone=>Octave Function
      Operating SystemMicrosoft Windows=>Any
    Thu 24 May 2012 06:36:42 PM UTCjweAttached File-=>Added mkdir-p-diffs.txt, #25916
      StatusFixed=>Postponed
      Open/ClosedClosed=>Open
    Wed 23 May 2012 08:39:58 PM UTCdbatemanStatusNone=>Fixed
      Assigned toNone=>dbateman
      Open/ClosedOpen=>Closed
    Wed 23 May 2012 11:24:11 AM UTCdbatemanAttached File-=>Added changeset, #25910
    Thu 16 Sep 2010 06:29:30 PM UTCjwePriority5 - Normal=>1 - Later
    Wed 04 Aug 2010 10:44:42 PM UTCrik5Severity3 - Normal=>1 - Wish
      Summarymkdir should create hierarchy=>Feature Request: mkdir should create hierarchy

    Back to the top


    Powered by Savane 3.1-cleanup1