[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nocaseglob doesn't always work as expected.
From: |
Bob Proulx |
Subject: |
Re: nocaseglob doesn't always work as expected. |
Date: |
Mon, 4 Oct 2010 09:43:42 -0600 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Alexey Vinogradov wrote:
> alexey@ubuntu64:/tmp$ shopt -u nocaseglob; shopt -s nullglob; for a in
> [B-C]* ; do echo $a; done
Since you do not mention your locale setting I assume that you are not
aware of how it affects ranges. Here if your locale setting uses
dictionary sort ordering then [B-C] is the same as [BcC].
$ echo b | env -i LC_ALL=en_US.UTF-8 grep '[B-C]'
$ echo B | env -i LC_ALL=en_US.UTF-8 grep '[B-C]'
B
$ echo c | env -i LC_ALL=en_US.UTF-8 grep '[B-C]'
c
$ echo C | env -i LC_ALL=en_US.UTF-8 grep '[B-C]'
C
In the above you can see that lower case c exists in the range B-C but
lower case b does not.
In a locale that sets dictionary sort ordering the collating sequence
is aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ.
[a-z] is the same as [aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYz]
[A-Z] is the same as [AbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ]
You can read more about locales in the online standards documentation.
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html#tag_08_02
Personally I set the following in my ~/.bashrc file.
export LANG=en_US.UTF-8
export LC_COLLATE=C
Bob