bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Curious case statement error


From: Eduardo Bustamante
Subject: Re: Curious case statement error
Date: Sat, 13 Aug 2016 19:59:10 +0000

Character ranges are locale-dependant. Check the values of LC_ALL and LC_COLLATE. Under some locales, the [A-Z] range is actually AaBb..Z. That's why it's better to use the character classes, i.e. [[:alpha:]], [[:lower:]], [[:upper:]], etc.

Unless you set the globasciiranges shopt:

  globasciiranges
If set, range expressions used in pattern matching bracket expressions (see Pattern Matching) behave as if in the traditional C locale when performing comparisons. That is, the current locale’s collating sequence is not taken into account, so ‘b’ will not collate between ‘A’ and ‘B’, and upper-case and lower-case ASCII characters will collate together.

Anyways, bash behavior here is correct. If you need some specific collation order make sure to set your LC_* variables correctly, or use the POSIX locale (LC_ALL=C)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]