Bug 118161

Summary: character class range glob patterns fail to honor upper or lower case
Product: [Fedora] Fedora Reporter: Joe Smith <jes>
Component: bashAssignee: Tim Waugh <twaugh>
Status: CLOSED NOTABUG QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: medium    
Version: 1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-03-12 18:26:17 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Joe Smith 2004-03-12 18:19:03 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040116

Description of problem:
Bash shell glob patterns using character class ranges fail to honor 
upper and lower case attribute.



Version-Release number of selected component (if applicable):
bash-2.05b-34

How reproducible:
Always

Steps to Reproduce:
Examples (see notes following):

[01] $ cd /usr/share/doc/bash-2.05b
[02] $ ls
article.ms   bashdb        builtins.ps  INTRO      rbash.0      
startup-files
article.ps   bash.html     CHANGES      loadables  rbash.ps
article.txt  bash.ps       COMPAT       misc       rose94.ps
bash.0       bashref.html  complete     NEWS       scripts
bashbug.0    bashref.ps    FAQ          NOTES      scripts.noah
bashbug.ps   builtins.0    functions    POSIX      scripts.v2
[03] $ ls -d c*
complete
[04] $ ls -d C*
CHANGES  COMPAT
[05] $ ls -d [C]*
CHANGES  COMPAT
[06] $ ls -d [A-Z]*
bash.0      bash.ps       CHANGES    INTRO      POSIX      scripts.noah
bashbug.0   bashref.html  COMPAT     loadables  rbash.0    scripts.v2
bashbug.ps  bashref.ps    complete   misc       rbash.ps   startup-files
bashdb      builtins.0    FAQ        NEWS       rose94.ps
bash.html   builtins.ps   functions  NOTES      scripts
[07] $ ls -d [C]*
CHANGES  COMPAT
[08] $ ls -d [BC]*
CHANGES  COMPAT
[09] $ ls -d [CF]*
CHANGES  COMPAT  FAQ
[10] $ ls -d [C-F]*
CHANGES  COMPAT  FAQ  functions
[11] $ ls -d *[C-F]*
article.ms   bashdb        CHANGES   FAQ        NEWS       startup-files
article.ps   bashref.html  COMPAT    functions  NOTES
article.txt  bashref.ps    complete  loadables  rose94.ps
[12] $ ls -d *[c-f]*
article.ms   bashref.html  complete   NEWS       scripts.noah
article.ps   bashref.ps    functions  NOTES      scripts.v2
article.txt  CHANGES       loadables  rose94.ps  startup-files
bashdb       COMPAT        misc       scripts
[13] $ echo $LANG
en_US.UTF-8
[14] $ LANG=C
[15]$ ls -d [A-Z]*
CHANGES  COMPAT  FAQ  INTRO  NEWS  NOTES  POSIX
[16] $ ls -d *[C-F]*
CHANGES  COMPAT  FAQ  NEWS  NOTES
[17] $ ls -d *[c-f]*
article.ms   bashdb        complete   misc       scripts.noah
article.ps   bashref.html  functions  rose94.ps  scripts.v2
article.txt  bashref.ps    loadables  scripts    startup-files



Actual Results:  See above.

Expected Results:  ([##] refers to steps above)

[01] - [05] ok
[06] Oops - expected only names starting with [A-Z]
[07] ok
[08] ok (simple char class, not range)
[09] ok (simple char class, not range)
[10] Oops - shouldn't list 'functions' (but skipped 'complete'! Why?)
[11] Oops - should list 'CHANGES  COMPAT  FAQ  NEWS  NOTES'
[12] Oops - includes C-F (but _not_ 'FAQ' - Why?)
[13] - [17] ok (seems it's a locale/utf-8 problem)


Additional info:

Workaround: set LANG=C

Note: POSIX classes don't seem to work at all, i.e. '[:lower:]' is
just a collection of characters.

Comment 1 Tim Waugh 2004-03-12 18:26:17 UTC
See the bash FAQ, question E9.  This is intentional behaviour.

http://www.faqs.org/faqs/unix-faq/shell/bash/

Comment 2 Joe Smith 2004-03-12 19:31:11 UTC
Sorry.  Shoulda figured that was too obvious.

So, why don't '[:upper:]' and so forth work?

$ ls -d *[0-9]*
bash.0  bashbug.0  builtins.0  rbash.0  rose94.ps  scripts.v2

ls -d *[:digit:]*
article.ms   bash.html   bashdb        builtins.ps  loadables 
scripts.noah
article.ps   bashbug.0   bashref.html  complete     misc       scripts.v2
article.txt  bashbug.ps  builtins.0    functions    scripts   
startup-files

This really breaks the principle of 'least suprise'.  Has anyone
considered doing as the FAQ auggests and adding 'LC_COLLATE=C' in
/etc/profile?

Sorry for the false report.


Comment 3 Tim Waugh 2004-03-12 22:26:06 UTC
[:digit:] is nothing to do with glob patterns.  Perhaps you're
thinking of regular expressions.

Comment 4 Joe Smith 2004-03-12 22:54:54 UTC
> So, why don't '[:upper:]' and so forth work?

Ok, so I'm a putz; it's what I get for reading the lousy man page. 
One decent example is all I'd need to get the idea:

(See http://tille.soti.org/training/bash/ch04s03.html)

$ cd /usr/share/doc/bash-2.05b/
$ ls -d *[[:digit:]]*
bash.0  bashbug.0  builtins.0  rbash.0  rose94.ps  scripts.v2

They also talk about LC_COLLATE on that soti.org page.

So we both had something to learn ;-)

Hopefully this (false) report will at least help the next poor luser
who get's clobbered by this and tries to file a bug report...