'tr' Bug

Eric Blake eblake@redhat.com
Fri Mar 11 15:53:00 GMT 2011


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20110311/077d0b07/attachment.sig>


More information about the Cygwin mailing list