dir listing not starting with . and ..

Jaroslav Hajek highegg at gmail.com
Wed Feb 4 09:13:42 CST 2009


On Wed, Feb 4, 2009 at 2:04 PM, Søren Hauberg <soren at hauberg.org> wrote:
> Hi
>
> With a recent checkout I see the following behaviour
>
>  octave:10> a = dir ("/tmp/oct-tylyzv");
>  octave:11> a (:).name
>  ans = statistics-1.0.4
>  ans = ..
>  ans = .
>
> As you can see the last element of the directory listing is ".", and the
> second last is "..". It used to be that this was reversed such that "."
> was always the first element, and ".." was always the second element.
> This is also what Matlab does.
>
> I discovered this issue because it is no possible for me to install
> packages in Octave, because 'pkg' assumes that the first "real"
> directory returned by 'dir' is number 3 in the list generated by 'dir'.
>
> Søren
>

My fault, due to an older change string_vector::sort was not working.
Patch uploaded:
http://hg.savannah.gnu.org/hgweb/octave/rev/4238f2600a17

Note that readdir (and, consequently, dir) simply sorts the result.
This does *not* ensure that . and .. go first.
If, for instance, a file named "(" exists, it will end up first. Worse
yet, this is compatible with Matlab 2007a.

So, maybe pkg should be fixed?

cheers

-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



More information about the Bug-octave mailing list