bugGNU Octave - Bugs: bug #47359, fileattrib wildcard/globbing...

 
 

bug #47359: fileattrib wildcard/globbing characters handling

Submitted by:  Lutz Mager <rocketsound>
Submitted on:  Mon 07 Mar 2016 05:57:48 PM UTC  
 
Category:  Octave Function Severity:  1 - Wish
Priority:  2 Item Group:  Matlab Compatibility
Status:  Need Info Assigned to:  None
Originator Name:  rocketsound Open/Closed:  Open
Release:  dev Operating System:  Microsoft Windows

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

Mon 07 Mar 2016 09:53:03 PM UTC, comment #4: 

I'll try to test it at the end of the weekend.

The official docs are quite unspecific about wildcards. I don't know what they mean by saying "To specify all names beginning with certain characters, add the wildcard character, ." However the "internal docs" are more specific and say something like "(...) fileattrib mydir\  recursively displays the attributes of 'mydir' and its contents (...)".

Lutz Mager <rocketsound>
Mon 07 Mar 2016 08:00:36 PM UTC, comment #3: 

Documentation on the Windows XP attrib command is here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/attrib.mspx.  There is a '/s' option which selects recursive descent and a '/d' option which includes directories in the recursive descent.

It may be that Matlab has not really coded their own fileattrib command, but simply call out to the Windows shell to do the work for them.  If so, this would be undocumented Matlab behavior that Octave is unlikely to copy.

At least on a *Nix system the obvious way to solve the original problem would be

[status, list] = unix ("find *");

On Windows, you could try something like

[status, list] = dos ("dir * /b /s /d");

Rik <rik5>
Project Administrator
Mon 07 Mar 2016 07:21:07 PM UTC, comment #2: 

There doesn't seem to be any indication that Matlab itself should even be doing what it appears to do (http://www.mathworks.com/help/matlab/ref/fileattrib.html?#inputarg_name).

Is there any way for you to test with Matlab on a Unix platform to see if this is general behavior, or in fact an oddity only of their own implementation on Windows?

Rik <rik5>
Project Administrator
Mon 07 Mar 2016 05:59:34 PM UTC, comment #1: 

I'm sorry, the example directory structure got lost, here's another version:

RootDir
|__Dir1
   |__Subdir1
      |__MyText.txt
   |__Subdir2
|__Dir2

Lutz Mager <rocketsound>
Mon 07 Mar 2016 05:57:48 PM UTC, original submission:  

The core function fileattrib handles the wildcard character * differently then Matlab does, with respect to finding subdirectories and -files. I noticed this while search for an easy way for finding all subdirectories that lie in a given root directory.

Let's say we have to the following directory and file structure:

RootDir
|__Dir1
   |__Subdir1
      |__MyText.txt
   |__Subdir2
|__Dir2

The following script will produce different outputs in Octave or Matlab.

[status, result, msgid] = fileattrib('C:\RootDir\*');
for i = 1:length(result)
  if (result(i).directory)
    fprintf('%s\n', result(i).Name);
  end
end

Octave's output:

C:\RootDir\Dir1
C:\RootDir\Dir2

Matlab's output:

C:\RootDir\Dir1\Subdir1
C:\RootDir\Dir1\Subdir2
C:\RootDir\Dir1
C:\RootDir\Dir2

A slightly altered version of the script (notice the second wildcard below) will find the directories one layer below in Octave but will trigger an error in Matlab.

[status, result, msgid] = fileattrib('C:\RootDir\*\*');
for i = 1:length(result)
  if (result(i).directory)
    fprintf('%s\n', result(i).Name);
  end
end

Again, Octave's output:

C:\RootDir\Dir1\Subdir1
C:\RootDir\Dir1\Subdir2

And the output of Matlab:

??? Improper index matrix reference.

Error in ==> mytest at 4
  if (result(i).directory)

You get the point. Octave's fileattrib follows an other logic then Matlab's version does.

Tested this on Windows XP and 7.

Lutz Mager <rocketsound>

 

(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 mtmiller (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rocketsound (Submitted the item)
  •  

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

    Only project members can vote.

     

     

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-03-25 mtmiller Release4.0.1-rc1 => dev
    2016-03-07 rik5 Priority5 - Normal => 2
    2016-03-07 mtmiller StatusNone => Need Info
    2016-03-07 rik5 Severity3 - Normal => 1 - Wish

    Back to the top


    Powered by Savane 3.5