From nobody@FreeBSD.org  Mon Nov 30 22:13:31 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id AC93C1065729
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 30 Nov 2009 22:13:31 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 9C1938FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 30 Nov 2009 22:13:31 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nAUMDUon065246
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 30 Nov 2009 22:13:30 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id nAUMDU0m065245;
	Mon, 30 Nov 2009 22:13:30 GMT
	(envelope-from nobody)
Message-Id: <200911302213.nAUMDU0m065245@www.freebsd.org>
Date: Mon, 30 Nov 2009 22:13:30 GMT
From: Erwin Hoffmann <feh@fehcom.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: 'tr' does not respect locale setting
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         141036
>Category:       bin
>Synopsis:       tr(1) does not respect locale setting
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 30 22:20:01 UTC 2009
>Closed-Date:    Wed Dec 02 16:55:32 UTC 2009
>Last-Modified:  Wed Dec 02 16:55:32 UTC 2009
>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@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:
State-Changed-From-To: open->closed 
State-Changed-By: jh 
State-Changed-When: Wed Dec 2 16:45:56 UTC 2009 
State-Changed-Why:  
See the COMPATIBILITY section in tr(1) manual page. If you want to convert 
a file to lower case you should use tr "[:upper:]" "[:lower:]". 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141036 
>Unformatted:
