bug-bash
[Top][All Lists]
Advanced

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

Re: documentation bug re character range expressions


From: Eric Blake
Subject: Re: documentation bug re character range expressions
Date: Fri, 03 Jun 2011 14:33:17 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10

On 06/03/2011 11:36 AM, Marcel (Felix) Giannelia wrote:
> It sounds to me like what you're saying is, the *only* uses of bracket
> range expressions guaranteed to be "portable" are things like [[:upper:]]
> and [[:lower:]]. But I put "portable" in quotation marks just then,
> because to my mind the word "portable" implies "has the same behaviour on
> all systems", whereas things like [[:upper:]] are locale-dependent; they
> change their behaviour depending on system settings.

Actually, that _is_ portable, because if you have the _same_ locale on
two different machines, you will get the _same_ locale-dependent
behaviors from those two machines.

But you do have a point - even POSIX admits that different vendors have
varying locale description files, so the "en_US" locale is not
consistent between two machines if the locale definitions were not
written by the same person.

> [0-9] presumably still works consistently across all platforms -- I hope?

[0-9] is a special case.  It is the _ONLY_ range that POSIX requires to
be invariant across all locales, so in practice, you can use this range
expression to your heart's content.  But there is still the POSIX
wording that [0-9] may have implementation-defined behavior for non-C
locales, so you might _still_ be safer using [0123456789] or [[:digit:]].

> 
> I think a good solution to this, then, is to just deprecate the use of "-"
> in bracket expressions entirely.

Which is effectively what POSIX did by stating that range expressions
outside of the C locale have unspecified effects.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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