bugGNU Octave - Bugs: bug #54489, exist and isdir should look for...

 
 

bug #54489: exist and isdir should look for directories on the load path for compatibility

Submitter:  Mike Miller <mtmiller>
Submitted:  Fri 10 Aug 2018 10:38:52 PM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Postponed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 13 Aug 2018 07:19:08 PM UTC, comment #3: 

I also can't see much need for the "feature" of searching through the loadpath so I think it is okay to leave this as postponed.

I made isdir.m a legacy function and updated Octave core to use isfolder instead.  See https://hg.savannah.gnu.org/hgweb/octave/rev/e04c56bbbace.

Rik <rik5>
Group administrator
Mon 13 Aug 2018 05:27:43 PM UTC, comment #2: 

I don't personally see a use case for 'exist' finding directories in the load path, so I don't feel strongly about it. But it is a compatibility issue. If you would rather keep 'isdir' as an alias for 'isfolder', we should do that and document that discrepancy, and the same with 'exist'.

But I do want to make sure that we explicitly define 'isfolder' to be independent of 'exist', in case it does change in the future. And I do want to be sure that existing code is upgraded to use 'isfolder' wherever possible.

Mike Miller <mtmiller>
Group Member
Mon 13 Aug 2018 04:23:15 PM UTC, comment #1: 

I was looking at the isfolder implementation as well, but I had a different idea.  Since isdir() in Octave already behaves like isfolder() is supposed to, I thought we might change the documentation on isdir to reference dir_in_loadpath() if you want that sort of lookup.  Otherwise, isdir and isfolder in Octave would be aliases for each other.

Rik <rik5>
Group administrator
Fri 10 Aug 2018 10:38:52 PM UTC, original submission:  

The Matlab function 'exist' looks for function files or mex files on the search path. If it is given an arbitrary file name, it also looks for that file on the search path. The same is true of directory names.


mkdir /tmp/mydir
addpath /tmp
exist ('mydir')         ## this should return 7
exist ('mydir', 'dir')  ## same


And the 'isdir' function follows the same logic, so it makes sense to be implemented using 'exist'. Fixing 'exist' will fix 'isdir', both should be documented as such.

Since 'isdir' may find directories on the load path, the new function 'isfolder' (see bug #54456) should be preferred if the code expects to be dealing only with relative or absolute directory names. I beleve 'isfolder' should be added first, and existing code migrated to 'isfolder', before we change the underlying behavior of 'isdir'.

We may also move 'isdir' to the scripts/legacy directory as part of this, since it is "not recommended" by Matlab.

Mike Miller <mtmiller>
Group Member

 

(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 mtmiller (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-13 rik5 Summaryexist and isdir should look for directories on the load path exist and isdir should look for directories on the load path for compatibility
    2018-08-13 mtmiller Priority5 - Normal 3 - Low

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code