GNU bug report logs -
#8587
Curious bug.
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8587 in the body.
You can then email your comments to 8587 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#8587
; Package
coreutils
.
(Fri, 29 Apr 2011 20:17:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Francois Boisson <francois <at> boisson.homeip.net>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Fri, 29 Apr 2011 20:17:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
On a debian squeeze amd64.
francois <at> totoche:~$ echo ABCD Directory | tr [:lower:] [:upper:]
ABCD DIRECTORY
francois <at> totoche:~$ cd /tmp
francois <at> totoche:/tmp$ echo ABCD Directory | tr [:lower:] [:upper:]
tr: construit [:upper:] et/ou [:lower:] mal aligné
francois <at> totoche:/tmp$ echo ABCD Directory | tr [:upper:] [:lower:]
llll lirectory
francois <at> totoche:/tmp$ cd
francois <at> totoche:~$ echo ABCD Directory | tr [:upper:] [:lower:]
abcd directory
francois <at> totoche:~$
francois <at> totoche:/tmp/g$ tr --version
tr (GNU coreutils) 7.4
Copyright © 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 ou ultérieure
<http://gnu.org/licenses/gpl.html>. Ceci est un logiciel "libre" : vous êtes
libre de le modifier et de le redistribuer. Ce logiciel n'offre pas d'autre
garantie que celle imposée par la loi.
Écrit par Jim Meyering.
francois <at> totoche:/tmp/g$
ii libc6 2.10.2-2 GNU C Library: Shared libraries
ii coreutils 7.4-2 The GNU core utilities
I can give you more informations if you want.
Thanks for this work.
François Boisson
Reply sent
to
Eric Blake <eblake <at> redhat.com>
:
You have taken responsibility.
(Fri, 29 Apr 2011 20:54:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Francois Boisson <francois <at> boisson.homeip.net>
:
bug acknowledged by developer.
(Fri, 29 Apr 2011 20:54:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 8587-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tag 8587 notabug
close 8587
thanks
On 04/29/2011 01:09 PM, Francois Boisson wrote:
> On a debian squeeze amd64.
>
> francois <at> totoche:~$ echo ABCD Directory | tr [:lower:] [:upper:]
> ABCD DIRECTORY
> francois <at> totoche:~$ cd /tmp
> francois <at> totoche:/tmp$ echo ABCD Directory | tr [:lower:] [:upper:]
> tr: construit [:upper:] et/ou [:lower:] mal aligné
Thanks for the report. However, this is not a bug in tr, but in your
usage of the shell.
Unquoted, the expression (without "") "[:lower:]" is the glob that
expands to any of the existing files: ":", "l", "o", "w", "e", "r"; and
if none of those files exists, then the glob is passed verbatim to tr.
Your results differed depending on whether the directory you were in had
files by those names.
But if you had used shell quoting, as in "'[:lower:]'", then there would
be no chance for the shell to do globbing. That is, you meant to do:
echo ABCD Directory | tr '[:lower:]' '[:upper:]'
and were only getting lucky that there weren't any one-character file
names in your first directory.
--
Eric Blake eblake <at> redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#8587
; Package
coreutils
.
(Fri, 29 Apr 2011 21:08:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 8587 <at> debbugs.gnu.org (full text, mbox):
On 29/04/11 20:09, Francois Boisson wrote:
> On a debian squeeze amd64.
>
> francois <at> totoche:~$ echo ABCD Directory | tr [:lower:] [:upper:]
> ABCD DIRECTORY
> francois <at> totoche:~$ cd /tmp
> francois <at> totoche:/tmp$ echo ABCD Directory | tr [:lower:] [:upper:]
> tr: construit [:upper:] et/ou [:lower:] mal aligné
So the operation is dependent on path.
That shows the shell is interpreting the params,
as demonstrated with:
$ touch l
$ echo [:lower:] [:upper:]
l [:upper:]
So you need to protect the params like:
$ tr '[:lower:]' '[:upper:]'
cheers,
Pádraig.
Added tag(s) notabug.
Request was from
Pádraig Brady <P <at> draigBrady.com>
to
control <at> debbugs.gnu.org
.
(Fri, 29 Apr 2011 21:12:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#8587
; Package
coreutils
.
(Fri, 29 Apr 2011 21:37:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 8587 <at> debbugs.gnu.org (full text, mbox):
Francois Boisson writes:
>
> On a debian squeeze amd64.
>
> francois <at> totoche:~$ echo ABCD Directory | tr [:lower:] [:upper:]
> ABCD DIRECTORY
> francois <at> totoche:~$ cd /tmp
> francois <at> totoche:/tmp$ echo ABCD Directory | tr [:lower:] [:upper:]
> tr: construit [:upper:] et/ou [:lower:] mal aligné
I can't read that error message but I can see what you did wrong.
[:upper:] is seen by the shell as a glob which matches these filenames:
:
e
p
r
u
and likewise [:lower:] matches a different set of single-character filenames.
In one directory, you don't have any files named like that. In the other
directory, you do. When the glob matches nothing, the shell passes the string
[:upper:] or [:lower:] literally as an argument to the command. That's a
design flaw in the unix shell from its early days, which nobody has the guts
to fix.
Use '[:upper:]' and '[:lower:]' to make the shell treat them as literal
strings and not globs.
Switch to zsh for better diagnostics...
% echo ABCD Directory | tr [:lower:] [:upper:]
zsh: no matches found: [:lower:]
% echo ABCD Directory | tr '[:lower:]' '[:upper:]'
ABCD DIRECTORY
--
Alan Curry
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#8587
; Package
coreutils
.
(Sat, 30 Apr 2011 01:14:02 GMT)
Full text and
rfc822 format available.
Message #21 received at submit <at> debbugs.gnu.org (full text, mbox):
On Fri, 29 Apr 2011 21:09:43 +0200
Francois Boisson <francois <at> boisson.homeip.net> wrote:
> On a debian squeeze amd64.
>
> francois <at> totoche:~$ echo ABCD Directory | tr [:lower:] [:upper:]
> ABCD DIRECTORY
> francois <at> totoche:~$ cd /tmp
> francois <at> totoche:/tmp$ echo ABCD Directory | tr [:lower:] [:upper:]
> tr: construit [:upper:] et/ou [:lower:] mal aligné
> francois <at> totoche:/tmp$ echo ABCD Directory | tr [:upper:] [:lower:]
> llll lirectory
> francois <at> totoche:/tmp$ cd
> francois <at> totoche:~$ echo ABCD Directory | tr [:upper:] [:lower:]
> abcd directory
> francois <at> totoche:~$
Not a bug.
[:upper:] and [:lower:] are also shell patterns, and if a file in the
current directory matches them, they are expanded before tr sees them.
My guess is that you have a file named "l" under /tmp, so what tr sees is
$ echo ABCD Directory | tr l [:upper:]
tr: misaligned [:upper:] and/or [:lower:] construct
$ echo ABCD Directory | tr [:upper:] l
llll lirectory
([:upper:], as a shell pattern, matches the characters ":", "u", "p", "e"
and "r"; [:lower:] matches the characters ":", "l", "o", "w", "e" and "r").
The solution, of course, is to protect the patterns from the shell by
quoting them:
$ echo ABCD Directory | tr '[:lower:]' '[:upper:]'
ABCD DIRECTORY
--
D.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#8587
; Package
coreutils
.
(Sat, 30 Apr 2011 13:16:01 GMT)
Full text and
rfc822 format available.
Message #24 received at 8587 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 04/29/2011 03:35 PM, Alan Curry wrote:
> Use '[:upper:]' and '[:lower:]' to make the shell treat them as literal
> strings and not globs.
>
> Switch to zsh for better diagnostics...
>
> % echo ABCD Directory | tr [:lower:] [:upper:]
> zsh: no matches found: [:lower:]
> % echo ABCD Directory | tr '[:lower:]' '[:upper:]'
> ABCD DIRECTORY
That's not specific to zsh. You can get that same behavior in bash:
$ echo [l]
[l]
$ shopt -s failglob
$ echo [l]
bash: no match: [l]
--
Eric Blake eblake <at> redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 29 May 2011 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 14 years and 26 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.