develooper Front page | perl.perl5.porters | Postings from September 2013

[perl #119785] bsd_glob does not sort case-sensitively

Thread Previous | Thread Next
James E Keenan via RT
September 16, 2013 23:22
[perl #119785] bsd_glob does not sort case-sensitively
Message ID:
On Mon Sep 16 15:43:36 2013, wrote:
> > Jim Keenan wrote:
> > I think we should ask:
> >
> > 1. Is this behavior expected and correct?
> >
> > 2. If it is, what changes do we have to make in 'ext/File-
>    Glob/'
> > so that a user of File::Glob will have the correct expectations?
> Now that I finally understand the File::Glob doc, I think the results
>    are correct (i.e. they match the documentation).
> 1) bsd_glob(PATTERN) === bsd_glob(PATTERN, GLOB_CSH)
> Relative to sorting,�
> GLOB_NOCASE affects the interpretation of PATTERN, so is not
>    applicable in this case, but when it is specified, it turns off the
>    default use of GLOB_CSH, thereby reverting to the default mentioned
>    in the GLOB_NOSORT paragraph, namely ASCII sort rather than
> GLOB_NOSORT returns a more or less randomly ordered list (depending on
>    the physical order of the entries in the directory.� You're getting
>    the result you got because of the order you created the files.� If
>    it had been different, you would have gotten a different order of
>    your results.
> GLOB_BRACE is similar to GLOB_NOCASE above, in that it affects the
>    interpretation of PATTERN, but it has the side effect of turning
>    off the default use of GLOB_CSH causing the behavior to revert to
>    ASCII sort.
> I don't know if you can make any changes to the code of File::Glob
>    without breaking backward compatibility.

Well, *I*, for one, am not attempting any changes in File::Glob's code.
 I don't think there's any cause for that and, in any event, that's
outside my expertise.  Even if we did want to make any code changes,
those changes would only apply to blead and 5.20; we wouldn't attempt
any backward-compatibility.

> I think a doc change is
>    needed to clarify that:
> Here's the crux of the issue:� With only one argument, the default is
>    exactly as if GLOB_CSH was used.� This is mentioned under the
>    bsd_glob() function description in the 5.16 and 5.18 documentation,
>    but it is not mentioned in older versions of the documentation.
>    Especially, it is not mentioned in the 5.18 documentation, in the
>    POSIX FLAGS section, that the flag defaults are *only* in effect if
>    **the second argument is specified**.� The word "default" is used a
>    couple of times in the POSIX FLAGS section, but those are only the
>    defaults if the second argument is specified!� It took me a long
>    time to figure that out.

I can look into this -- but if others wish to comment on File::Glob's
*documentation*, they should speak now.

> As a side note, I wish there were a tag that would export bsd_glob()

In order to keep the discussion focused and the ticket potentially
closable, I'm going to ask that if you want any changes in File::Glob's
code/behavior for 5.20+, you file a new perlbug with that request.

> The bottom line is
>    that I've decided to avoid File::Glob (and glob(), etc) and use my
>    own hand-rolled function, since I have to support code on perl
>    5.8.8.

Perl 5.8.8 is long out-of-support, so if you need to support File::Glob,
glob() or anything else on that version, you'll have to do a lot of
hand-rollling :-)

Thank you very much.
Jim Keenan

via perlbug:  queue: perl5 status: open

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About