helpThe GNU Bourne-Again SHell - Support: sr #108609, In en-US.UTF-8 locale, '*[A-Z]*'...


sr #108609: In en-US.UTF-8 locale, '*[A-Z]*' matches very oddly

Submitted by:  None
Submitted on:  Thu 03 Jul 2014 02:42:38 AM UTC  
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Invalid
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Wed 25 Mar 2015 10:46:24 AM UTC, comment #2: 

Not a bug.

That's just how character sets work. If you want the set of upper case characters, use [:upper:].

The locale specifies the ordering, so I guess under this locale, [A-Z] means: [AbBcCdD..zZ], that's why it doesn't match 'a'.

The only locale guaranteed to have that ordering for ranges ([a-z], [A-Z], ...) is the POSIX locale (LANG=C or LANG=POSIX)

Eduardo Bustamante <dualbus>
Thu 03 Jul 2014 03:13:56 AM UTC, comment #1: 

My attempt to use markup formatting appears to have caused the web interface to not display the text, so here is the plain version (minus the first line, which did come through). My apologies if this is redundant.

The demonstration:

$ cat Demo
# shell script
for i in "$@"; do
  case "$i" in
    [A-Z]) echo "$i has upper case";;
$ env - LANG=en_US.UTF-8 ./bash ./Demo a b C y z
b has upper case
C has upper case
y has upper case
z has upper case

This was tested with a fresh-compiled build from the latest git tip on 64-bit Ubuntu 14.04. I can (re)produce this behavior in at least Bash 4.3.11 (Ubuntu 14.04), 4.2.47 (Fedora 20), and 4.2.25 (Ubuntu 12.04).

Assuming that it is desirable for '*[A-Z]*' to match lower case characters at all in this context (I believe that it is a mistake to do so and it certainly doesn't match the behavior of other POSIX-compatible shells), bash should at least match 'a' too.

A mirror image of this bug happens if you use '*[a-z]*' and test against upper case letters; 'Z' does not match although A-Y do.

Chris Siebenmann <cks>
Thu 03 Jul 2014 02:42:38 AM UTC, original submission:  

It's easiest to show this as a demonstration:



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by chet (Updated the item)
  • -email is unavailable- added by dualbus (Posted a comment)
  • -email is unavailable- added by dennisne
  • -email is unavailable- added by cks (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-11-13 chet StatusNone => Invalid
    2014-07-04 dennisne Carbon-Copy- => Added

    Back to the top

    Powered by Savane 3.5