Bug 940903 - Bash ignores case when globbing
Summary: Bash ignores case when globbing
Status: RESOLVED UPSTREAM
Alias: None
Product: openSUSE Distribution
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: 13.2
Hardware: Other Other
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Dr. Werner Fink
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-07 00:33 UTC by George Baltz
Modified: 2015-08-13 06:58 UTC (History)
1 user (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description George Baltz 2015-08-07 00:33:35 UTC
Trying to select files using [a-z]* to only see files starting with lower case letter, bash gives me all files.  Works fine in csh and ksh.

Sample output: (bash is my login shell)
gwb@callahans:~> echo [a-z]*      
Backups bin BOINC Calibre Library Desktop Documents Downloads gui_rpc_auth.cfg isos kde logs Music Pictures Public public_html RasPi RPMs src Templates tmp Videos
gwb@callahans:~> csh
/home/gwb% echo [a-z]*
bin gui_rpc_auth.cfg isos kde logs public_html src tmp
/home/gwb% exit
exit
gwb@callahans:~> ksh
gwb@callahans:/home/gwb> echo [a-z]*
bin gui_rpc_auth.cfg isos kde logs public_html src tmp
gwb@callahans:/home/gwb> exit
gwb@callahans:~> shopt nocaseglob
nocaseglob      off
gwb@callahans:~> echo $LANG
en_US.UTF-8

Setting or clearing noglobcase has no effect:
gwb@callahans:~> shopt nocaseglob
nocaseglob      off
gwb@callahans:~> echo [a-z]*
Backups bin BOINC Calibre Library Desktop Documents Downloads gui_rpc_auth.cfg isos kde logs Music Pictures Public public_html RasPi RPMs src Templates tmp Videos
gwb@callahans:~> shopt -s nocaseglob
gwb@callahans:~> echo [a-z]*
Backups bin BOINC Calibre Library Desktop Documents Downloads gui_rpc_auth.cfg isos kde logs Music Pictures Public public_html RasPi RPMs src Templates tmp Videos
gwb@callahans:~> shopt nocaseglob
nocaseglob      on
gwb@callahans:~> shopt -u nocaseglob
Comment 1 George Baltz 2015-08-07 00:45:03 UTC
Same results on Tumbleweed 20150802.
Comment 2 Dr. Werner Fink 2015-08-12 12:36:43 UTC
Sorry but this is how bash works.  Btw: nocaseglob does work

  cd /var/log
  echo [a-z]* | grep -E '^[A-Z]'| wc -c
  0
  shopt -s nocaseglob 
  d136:log # echo [a-z]* | grep -E '^[A-Z]' | wc -c
  439
Comment 3 George Baltz 2015-08-12 17:12:16 UTC
No, this is not how bash should work.

Another test:

gwb@callahans:~> mkdir /tmp/playground
gwb@callahans:~> cd /tmp/playground
gwb@callahans:/tmp/playground> touch a A
gwb@callahans:/tmp/playground> echo [a-z]
a A
gwb@callahans:/tmp/playground> echo [A-Z]
A
gwb@callahans:/tmp/playground> shopt -s nocaseglob
gwb@callahans:/tmp/playground> echo [a-z]
a A
gwb@callahans:/tmp/playground> echo [A-Z]
a A
gwb@callahans:/tmp/playground> 


So nocaseglob does something, but it's still not right (or even consistent). The first echo should only show 'a'.

As I said, this does work correctly (i.e., only displays the matching case) in both csh and ksh.
Comment 4 George Baltz 2015-08-12 17:21:11 UTC
And even more strangeness...

Continuing my last test:

gwb@callahans:/tmp/playground> touch b B
gwb@callahans:/tmp/playground> echo [A-Z]
a A b B
gwb@callahans:/tmp/playground> shopt -u nocaseglob
gwb@callahans:/tmp/playground> echo [a-z]
a A b B
gwb@callahans:/tmp/playground> echo [A-Z]
A b B

So it works only on the first field???
Comment 5 Dr. Werner Fink 2015-08-13 06:58:49 UTC
Run

      bashbug

and report upstream