This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with Bash regex test case sensitivity


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   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]