misc/141036: 'tr' does not respect locale setting

Erwin Hoffmann feh at fehcom.de
Mon Nov 30 22:20:02 UTC 2009


>Number:         141036
>Category:       misc
>Synopsis:       'tr' does not respect locale setting
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 30 22:20:01 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Erwin Hoffmann
>Release:        6.4
>Organization:
FEHCom
>Environment:
FreeBSD artemis.fehnet.de 6.4-RELEASE FreeBSD 6.4-RELEASE #0: Wed Nov 26 11:43:51 UTC 2008     root at dessler.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
The use of 'tr' (system tool translate) behaves erroneous in case of different locale settings.

a) My setting in /etc/login.conf (see manual; compiled):

##
german:German Users Accounts:\
    :charset=ISO-8859-15:\
    :lang=de_DE.ISO8859-15:\
    :tc=default:

My account as per vipw:

erwin:X:1002:1001:german:0:0:Erwin Hoffmann:/home/erwin:/usr/local/bin/bash

b) My local bash environment (without X): 

MM_CHARSET=ISO-8859-15
SHELL=/usr/local/bin/bash
TERM=cons25l1
USER=erwin
ENV=/home/erwin/.shrc
PAGER=more
FTP_PASSIVE_MODE=YES
MAIL=/var/mail/erwin
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/home/erwin/bin
BLOCKSIZE=K
PWD=/home/erwin
EDITOR=vi
LANG=de_DE.ISO8859-15
SHLVL=1
HOME=/home/erwin
LOGNAME=erwin
_=/usr/bin/env

c) Now I use the following file:

// C Test program

#include <"MYHEADER.H">

void main {

return;

}

-- This is a sample for my students --

d) Now, I use:

cat text.c | tr '[A-Z]' [a-z]'

e) This results in:

cat text.c | tr '[A-Z]' '[a-z]'
// c ßest program

#include <"mxheader.h">

void main {

return;

}


--- 

The result is obvious wrong.
My students are scared about FreeBSD.










>How-To-Repeat:
Change system login.conf and recompile.
Provide environment as descriped.
Use the file as defined above and apply the 'tr' command.
>Fix:
Hm. tr uses probably a simple counter logic with ANSI C character codings.
tr should check the current settings instead of using the default mapping.

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list