Problem with Bash regex test case sensitivity
Sun Dec 5 00:15:00 GMT 2010
On 12/04/2010 02:49 PM, Lee Rothstein wrote:
> Therefore, instead of using '[A-Z]' to represent caps, I should
> have used (?) the Posixly Correct, '[:upper:]'.
POSIX 2001 and 2008 says that [A-Z] when used as a glob or as a regex is
defined _only_ in the C locale; in all other locales, it's behavior is
unspecified. Meanwhile, [[:upper:]] (note the double [ and ]) is
well-defined in all locales (the next version of POSIX will make it more
obvious that [:upper:] might be treated as either [:epru] or
[[:upper:]], if not outright rejected as an error). It all stems from
the earlier POSIX 1992, which required [A-Z] to match collation order in
all locales. POSIX 2001 withdrew that requirement based on how many
people it confused, but the damage was already done - it is no longer
portable because of people that literally implemented the older
requirement (bash included).
Now, what would be really nice is if all implementations treated
unspecified behavior for [A-Z] as meaning a sane synonym for
[[:upper:]], but that's not going to happen any time soon.
Eric Blake email@example.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 619 bytes
Desc: OpenPGP digital signature
More information about the Cygwin