Bug 118161 - character class range glob patterns fail to honor upper or lower case
character class range glob patterns fail to honor upper or lower case
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: bash (Show other bugs)
1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-03-12 13:19 EST by Joe Smith
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-03-12 13:26:17 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Joe Smith 2004-03-12 13:19:03 EST
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 13:26:17 EST
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 14:31:11 EST
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 17:26:06 EST
[:digit:] is nothing to do with glob patterns.  Perhaps you're
thinking of regular expressions.
Comment 4 Joe Smith 2004-03-12 17:54:54 EST
> 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...

Note You need to log in before you can comment on or make changes to this bug.