[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug on [A-Z] and [a-z]

From: Jonathan Nieder
Subject: Re: bug on [A-Z] and [a-z]
Date: Sun, 1 May 2011 21:17:49 -0500
User-agent: Mutt/1.5.21 (2010-09-15)


address@hidden wrote:

>       When  running "echo [A-Z]*" , it shows all files/dirs of current
>     directory, not only those starting with capital letters. I tried
>     different locales such as: POSIX, C, en_US, pt_BR
> Repeat-By:
>     $ mkdir a && cd a
>     $ touch a b c; mkdir D E F
>     $ echo [A-Z]*
>     b c D E F
>     $ echo [a-z]*
>     a b c D E F

See http://bugs.debian.org/301717 (“fnmatch("[a-z]", ...) matches
capital letters in most locales”) for some details.

I'm puzzled by your comment on trying different locales, though:
I tried

        mkdir a && cd a
        touch a b c; mkdir D E F
        echo [A-Z]*

and got output

        b c D E F

as expected.  Then I tried

        export LANG
        echo [A-Z]*

and got output

        D E F

Does your experience differ?  I'm using 4.1.5(1)-release fwiw.

>     No Fix yet, looking on the source code.

In the long run, a good fix might be to teach fnmatch a new
FNM_STRICTCASE flag and optionally use it.  The hardest part would
seem to be making tables so the system can know what "this range,
using the same case" means.  If you'd like to work on this, please
feel free to coordinate using the aforementioned libc bug report (and
cc-ing me).

A separate aspect is documentation.  I imagine Chet wouldn't mind
a patch to bash.1 and bash.info to explain this pitfall under
"Pattern Matching" or even under "BUGS" (aka LIMITATIONS).

Hope that helps,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]