Filename globbing has a strange behaviour, according to the nocaseglob shell variable (bash-2.05a-13) : bash-2.05a$ mkdir /tmp/test bash-2.05a$ cd /tmp/test bash-2.05a$ touch xx yy ZZ YY bash-2.05a$ shopt -u nocaseglob bash-2.05a$ echo [a-z]* xx yy YY bash-2.05a$ shopt -s nocaseglob bash-2.05a$ echo [a-z]* xx yy YY ZZ --> I'd expect [a-z]* to glob to xx yy only when nocaseglob in unset. Note : According to the Pattern Matching section of the bash manual, I checked that my LC_COLLATE has not an exotic value : it's unset.
And 'locale' says?
bash-2.05a$ locale LANG=en_US LC_CTYPE="en_US" LC_NUMERIC="en_US" LC_TIME="en_US" LC_COLLATE="en_US" LC_MONETARY="en_US" LC_MESSAGES="en_US" LC_PAPER="en_US" LC_NAME="en_US" LC_ADDRESS="en_US" LC_TELEPHONE="en_US" LC_MEASUREMENT="en_US" LC_IDENTIFICATION="en_US" LC_ALL=
It is collating according to en_US rules. You forgot to use 'LANG=C' if you wanted C-locale collation.
Setting C-locale didn't change the behaviour : bash-2.05a$ export LANG=C bash-2.05a$ locale LANG=C LC_CTYPE="C" LC_NUMERIC="C" LC_TIME="C" LC_COLLATE="C" LC_MONETARY="C" LC_MESSAGES="C" LC_PAPER="C" LC_NAME="C" LC_ADDRESS="C" LC_TELEPHONE="C" LC_MEASUREMENT="C" LC_IDENTIFICATION="C" LC_ALL= bash-2.05a$ touch xx yy ZZ YY bash-2.05a$ shopt -u nocaseglob bash-2.05a$ echo [a-z]* xx yy YY bash-2.05a$ shopt -s nocaseglob bash-2.05a$ echo [a-z]* xx yy YY ZZ bash-2.05a$ ls YY ZZ xx yy I'd say it looks like a boundary problem when globbing [a-z], because if I substitute the filename ZZ with another one in uppercase, strictly included in the a-z range, this filename is globbed, independantly of the value of the 'nocaseglob' option : bash-2.05a$ rm ZZ bash-2.05a$ touch XX bash-2.05a$ shopt -u nocaseglob bash-2.05a$ echo [a-z]* xx XX yy YY bash-2.05a$ shopt -s nocaseglob bash-2.05a$ echo [a-z]* xx XX yy YY bash-2.05a$ ls XX YY xx yy Did I forget something else ? It looks strange and unexpected to me.
By the way, [[:upper:]] and [[:lower:]] show me an expected behaviour with the C locale : bash-2.05a$ ls -l total 0 -rw-r--r-- 1 bellet users 0 Nov 5 18:49 XX -rw-r--r-- 1 bellet users 0 Nov 5 18:47 YY -rw-r--r-- 1 bellet users 0 Nov 5 18:47 xx -rw-r--r-- 1 bellet users 0 Nov 5 18:47 yy bash-2.05a$ shopt -s nocaseglob bash-2.05a$ echo [[:lower:]]* xx XX yy YY bash-2.05a$ echo [[:upper:]]* [[:upper:]]* bash-2.05a$ shopt -u nocaseglob bash-2.05a$ echo [[:lower:]]* xx yy bash-2.05a$ echo [[:upper:]]* XX YY
Then perhaps you are seeing bug #74701, where changing the LANG shell variable doesn't call setlocale? Try 'LANG=C bash'.
Yes, it works in this case. Thanks and sorry for the false alarm :-)
*** Bug 182497 has been marked as a duplicate of this bug. ***