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: 'tr' Bug


On 03/11/2011 08:34 AM, marco atzeri wrote:
> $ echo /opt/IBN/df | tr [A-Z] [a-z]
> /opt/ibn/df
> 
> $ uname -a
> CYGWIN_NT-5.1 1.7.8(0.236/5/3) 2011-03-01 09:36 i686 Cygwin
> 
> $ set |grep LANG
> LANG=C.UTF-8

One more thing to note.  According to POSIX,

tr '[A-Z]' '[a-z]' is only portable in the POSIX (aka C) locale.  In all
other locales, that behavior is unspecified (for example, [A-Z] is
allowed to expand to AbBcC...yYzZ in locales that prefer that default
collation is case-insensitive), and you instead have to use:

tr '[:upper:]' '[:lower:]'

according to POSIX.  But then you run into problems with older Solaris
tr that doesn't understand the newer POSIX wording, so in practice, the
only multi-platform portable way to do case changing is to spell it out
yourself:

tr ABCDE...XYZ abcde...xyz

-- 
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]