From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 19 12:15:49 2012 Received: (at submit) by debbugs.gnu.org; 19 Jul 2012 16:15:50 +0000 Received: from localhost ([127.0.0.1]:50910 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SrtOG-0008Ga-SC for submit@debbugs.gnu.org; Thu, 19 Jul 2012 12:15:49 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34089) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SrkWV-0000HG-H0 for submit@debbugs.gnu.org; Thu, 19 Jul 2012 02:47:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrkQW-0008Qq-Pk for submit@debbugs.gnu.org; Thu, 19 Jul 2012 02:41:33 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, HTML_FONT_FACE_BAD, HTML_MESSAGE, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:59964) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrkQW-0008Qm-Ml for submit@debbugs.gnu.org; Thu, 19 Jul 2012 02:41:32 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrkQU-0007Jj-Ql for bug-coreutils@gnu.org; Thu, 19 Jul 2012 02:41:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrkQS-0008Pu-Ku for bug-coreutils@gnu.org; Thu, 19 Jul 2012 02:41:29 -0400 Received: from demumfd001.nsn-inter.net ([93.183.12.32]:13174) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrkQS-0008PM-7E for bug-coreutils@gnu.org; Thu, 19 Jul 2012 02:41:28 -0400 Received: from demuprx017.emea.nsn-intra.net ([10.150.129.56]) by demumfd001.nsn-inter.net (8.12.11.20060308/8.12.11) with ESMTP id q6J6fNP6006878 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 19 Jul 2012 08:41:24 +0200 Received: from demuexc022.nsn-intra.net (demuexc022.nsn-intra.net [10.150.128.35]) by demuprx017.emea.nsn-intra.net (8.12.11.20060308/8.12.11) with ESMTP id q6J6fNGl001130 for ; Thu, 19 Jul 2012 08:41:23 +0200 Received: from CNBEEXC007.nsn-intra.net ([10.159.192.12]) by demuexc022.nsn-intra.net with Microsoft SMTPSVC(6.0.3790.4675); Thu, 19 Jul 2012 08:41:23 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01CD6579.2B8B8FCC" Subject: tr bug Date: Thu, 19 Jul 2012 14:38:55 +0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: tr bug Thread-Index: Ac1leStVk+tinlOgTTGFS34s0GotGg== From: "Xiao, Bellon (NSN - CN/Cheng Du)" To: X-OriginalArrivalTime: 19 Jul 2012 06:41:23.0560 (UTC) FILETIME=[83851E80:01CD6579] X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-size: 8137 X-purgate-ID: 151667::1342680085-000055D8-40A5EF71/0-0/0-0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 19 Jul 2012 12:15:47 -0400 Cc: "Han, Cathy \(NSN - CN/Cheng Du\)" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) This is a multi-part message in MIME format. ------_=_NextPart_001_01CD6579.2B8B8FCC Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Hi, We found a bug of tr, the version is tr (coreutils) 5.2.1 Here is the symptom: When there is a file named e or r under current directory, tr will take = effect=A3=AClike=A3=BA echo hello |tr [a-z] [A-Z]=20 echo hello |tr [:lower:] [:upper:] will return hello And when is a file named l, o, p, u or w under current directory, tr = will give error message like: echo hello |tr [a-z] [A-Z]=20 echo hello |tr [:lower:] [:upper:] gives : tr: misaligned [:upper:] and/or [:lower:] construct But if you try=20 echo kkhh |tr "[a-z]" "[A-Z]"=20 echo kkhh |tr "[:lower:]" "[:upper:]" There will be no error and it takes effect. Brs Bellon Xiao ------_=_NextPart_001_01CD6579.2B8B8FCC Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable tr bug

Hi,

We found a bug = of tr, the version is tr = (coreutils) 5.2.1

Here is the symptom:

When there is a file named e or r under current = directory, tr will take effect=A3=AClike=A3=BA

        echo = hello |tr [a-z] [A-Z]

        echo hello |tr [:lower:] = [:upper:]

will return = hello

And when is a = file named l, = o, p, u or w under = current directory, tr will give error message like:

        echo = hello |tr [a-z] [A-Z]

        echo hello |tr [:lower:] = [:upper:]

gives = : tr: misaligned [:upper:] and/or = [:lower:] construct


But if you try

        echo kkhh |tr = "[a-z]" "[A-Z]"

        echo kkhh |tr = "[:lower:]" "[:upper:]"

There will be = no error and it takes effect.

Brs

Bellon = Xiao

------_=_NextPart_001_01CD6579.2B8B8FCC-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 19 12:45:03 2012 Received: (at 11991) by debbugs.gnu.org; 19 Jul 2012 16:45:04 +0000 Received: from localhost ([127.0.0.1]:51022 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SrtqY-0000ZJ-BV for submit@debbugs.gnu.org; Thu, 19 Jul 2012 12:45:03 -0400 Received: from joseki.proulx.com ([216.17.153.58]:39635) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SrtqV-0000Yh-5O; Thu, 19 Jul 2012 12:45:00 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id C807E2122D; Thu, 19 Jul 2012 10:38:42 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id 802D82DC62; Thu, 19 Jul 2012 10:38:42 -0600 (MDT) Date: Thu, 19 Jul 2012 10:38:42 -0600 From: Bob Proulx To: "Xiao, Bellon (NSN - CN/Cheng Du)" Subject: Re: bug#11991: tr bug Message-ID: <20120719163842.GA14362@hysteria.proulx.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11991 Cc: 11991@debbugs.gnu.org, "Han, Cathy \(NSN - CN/Cheng Du\)" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) retitle 11991 shell file globbing confusion tag 11991 + notabug close 11991 thanks Xiao, Bellon (NSN - CN/Cheng Du) wrote: > We found a bug of tr, the version is tr (coreutils) 5.2.1 Thank you for your report. But this is not a bug in tr but simply a misunderstanding of how your command line shell is working. It is a behavior of the shell and doesn't have anything to do with tr. > Here is the symptom: > When there is a file named e or r under current directory, Here you have made the critical description saying that there are files in the current directory. Shell file globbing is matching those files. You need to quote your arguments to prevent this. > tr will take effect=EF=BC=8Clike=EF=BC=9A > echo hello |tr [a-z] [A-Z]=20 > echo hello |tr [:lower:] [:upper:] > will return hello Those command lines are insufficiently quoted and therefore incorrect. > But if you try=20 > echo kkhh |tr "[a-z]" "[A-Z]"=20 > echo kkhh |tr "[:lower:]" "[:upper:]" > There will be no error and it takes effect. And there you see that you are quoting the arguments to prevent the shell from expanding them. Also the collating sequence depends upon your specific locale. The collation sequence of [a-z] in dictionary ordering is really "aAbBcC...xXyYzZ" and not "abc...z". So when you say "[a-z]" you are getting "aAbBcC...xXyYz" without 'Z' and when you say "[A-Z]" you are really getting "AbBcC...xXyYzZ" with 'A'! In the en_US.UTF-8 locale (for example) what would traditionally have been [A-Z] and [a-z] now must be specified as [:upper:] and [:lower:] instead. (And for grep, sed, awk and other tools you would need to put those in a character class [...] so you want two brackets there with [[:lower:]] and [[:upper:]].) Instead of 'tr' try using 'echo' to see what command line you are actually passing to the tr command. $ echo tr [a-z] [A-Z] $ echo tr [:lower:] [:upper:] $ echo tr "[a-z]" "[A-Z]" $ echo tr "[:lower:]" "[:upper:]" By running the above commands in directories containing single characters and you won't see the arguments verbatim to the command unless you quote them. Since this concerns the shell and not tr I am going to go ahead and mark the bug as closed to clear up the accounting. But please feel free to continue discussing the issue. Bob From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 19 12:50:35 2012 Received: (at 11991-done) by debbugs.gnu.org; 19 Jul 2012 16:50:35 +0000 Received: from localhost ([127.0.0.1]:51043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Srtvu-0000iF-Hp for submit@debbugs.gnu.org; Thu, 19 Jul 2012 12:50:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52170) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Srtvq-0000i1-UH; Thu, 19 Jul 2012 12:50:32 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6JGiHTt017164 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 19 Jul 2012 12:44:17 -0400 Received: from [10.3.113.102] (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6JGiGqq014447; Thu, 19 Jul 2012 12:44:17 -0400 Message-ID: <5008395F.3000606@redhat.com> Date: Thu, 19 Jul 2012 10:44:15 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: "Xiao, Bellon (NSN - CN/Cheng Du)" Subject: Re: bug#11991: tr bug References: In-Reply-To: X-Enigmail-Version: 1.4.3 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig1245A6219A73A65B35B79926" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 11991-done Cc: 11991-done@debbugs.gnu.org, "Han, Cathy \(NSN - CN/Cheng Du\)" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig1245A6219A73A65B35B79926 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable tag 11991 notabug thanks [Your message was encoded in Chinese; these days, you are more likely to achieve interoperability if you encode in UTF-8 instead] On 07/19/2012 12:38 AM, Xiao, Bellon (NSN - CN/Cheng Du) wrote: > Hi, >=20 > We found a bug of tr, the version is tr (coreutils) 5.2.1 That's extremely old. Have you considered updating? The latest stable version is 8.17, and there have been fixes to tr in the meantime (but not for your particular issue). > Here is the symptom: > When there is a file named e or r under current directory, tr will take= effect=EF=BC=8Clike=EF=BC=9A > echo hello |tr [a-z] [A-Z]=20 > echo hello |tr [:lower:] [:upper:] You are missing shell quoting. > will return hello >=20 > And when is a file named l, o, p, u or w under current directory, tr wi= ll give error message like: > echo hello |tr [a-z] [A-Z]=20 > echo hello |tr [:lower:] [:upper:] > gives : tr: misaligned [:upper:] and/or [:lower:] construct Try the following to see the difference shell quoting makes: echo tr [a-z] [A-Z] echo tr '[a-z]' '[A-Z]' The shell is expanding your glob before 'tr' ever sees the command line, because you happened to have files that matched the glob; in turn, that means you weren't executing the tr arguments that you thought you were. The quoting is necessary to avoid shell globbing from interfering. I'm therefore closing this as not a bug in coreutils, but in your usage pattern. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig1245A6219A73A65B35B79926 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJQCDlgAAoJEKeha0olJ0NqM/QH/As63fgYFbteroYiSfGAOtzs m3Zz3Xdtg4lcrILDqFOq3D5gogLlWuo7J5/2tZubYo5iuRZnQXeOWK7GbDWdBUQW y+Lt2pKBgxRw8zXbNYf8Ik4Z0ORTpbQ/pBzN0FQTo2uMwVMtzBkfNa8YfD0rCl/5 RZKWVFBHqeh7OZc2s67r/sDdGu0+ho0RmXTJVkO6eNMZUFT9XugVxZGn46r+xM6t JqgEtfeNi7oZhzNQgGzJDRL+kTnyGeK8AcXPlrC95dXb1LZ3TWuMM8p9BWEY1ehu h64KSedFfhix06dA8P8fmxK4xc6Lvw19J6LabVsByblt7VEkvVlD20QWoB7kY+Q= =OC98 -----END PGP SIGNATURE----- --------------enig1245A6219A73A65B35B79926-- From unknown Sat Jun 21 10:29:20 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 17 Aug 2012 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator