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 ebl...@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature