GNU bug report logs -
#13295
Possible bug - tr utility
Previous Next
Reported by: "Killen, Randy" <rkillen <at> frk.com>
Date: Fri, 28 Dec 2012 19:18:02 UTC
Severity: normal
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13295 in the body.
You can then email your comments to 13295 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#13295
; Package
coreutils
.
(Fri, 28 Dec 2012 19:18:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Killen, Randy" <rkillen <at> frk.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Fri, 28 Dec 2012 19:18:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello -
I encountered the situation shown below so thought that I would report it to see if it might be a bug or is expected behavior. Please let me know if you need additional information.
Randy
$
$ echo something | tr [:lower:] [:upper:]
SOMETHING
$ echo something | tr '[:lower:]' '[:upper:]'
SOMETHING
$
$ touch l
$ echo something | tr [:lower:] [:upper:]
tr: misaligned [:upper:] and/or [:lower:] construct
$ echo something | tr '[:lower:]' '[:upper:]'
SOMETHING
$ rm l
$
$ touch u
$ echo something | tr [:lower:] [:upper:]
tr: misaligned [:upper:] and/or [:lower:] construct
$ echo something | tr '[:lower:]' '[:upper:]'
SOMETHING
$ rm u
$
$ touch l
$ touch u
$ echo something | tr [:lower:] [:upper:]
something
$ echo something | tr '[:lower:]' '[:upper:]'
SOMETHING
$ rm l
$ rm u
$
$
$ uname -srvo
Linux 2.6.18-274.18.1.0.1.el5 #1 SMP Thu Feb 9 19:07:16 EST 2012 GNU/Linux
$ echo $SHELL
/bin/bash
$
Notice: All email and instant messages (including attachments) sent to
or from Franklin Templeton Investments (FTI) personnel may be retained,
monitored and/or reviewed by FTI and its agents, or authorized
law enforcement personnel, without further notice or consent.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#13295
; Package
coreutils
.
(Fri, 28 Dec 2012 23:48:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 13295 <at> debbugs.gnu.org (full text, mbox):
Hi Randy,
On 12/28/2012 06:37 PM, Killen, Randy wrote:
> Hello -
>
> I encountered the situation shown below so thought that I would report it to see if it might be a bug or is expected behavior. Please let me know if you need additional information.
>
> Randy
>
>
> $
> $ echo something | tr [:lower:] [:upper:]
> SOMETHING
> $ echo something | tr '[:lower:]' '[:upper:]'
> SOMETHING
> $
> $ touch l
> $ echo something | tr [:lower:] [:upper:]
> tr: misaligned [:upper:] and/or [:lower:] construct
> $ echo something | tr '[:lower:]' '[:upper:]'
> SOMETHING
> $ rm l
> $
> $ touch u
> $ echo something | tr [:lower:] [:upper:]
> tr: misaligned [:upper:] and/or [:lower:] construct
> $ echo something | tr '[:lower:]' '[:upper:]'
> SOMETHING
> $ rm u
> $
> $ touch l
> $ touch u
> $ echo something | tr [:lower:] [:upper:]
> something
> $ echo something | tr '[:lower:]' '[:upper:]'
> SOMETHING
> $ rm l
> $ rm u
This is expected behavior, caused by lack of quoting that results in the
shell (Bash) interpreting [...] as a wildcard pattern for file name
globbing (see glob(7)). If the 'nullglob' option of the shell is
disabled (use 'shopt nullglob' to display the current setting), a
wildcard that matches no files is kept as is. Thus the wildcards
[:lower:] and [:upper:] are either replaced by l resp. u if one of those
files exist or kept, if no matching file exists.
Quoting the special characters '[' and ']' by using '[:lower:]' resp.
'[:upper:]' (including the quotes) inhibits the shell from interpreting
them as file globbing wildcards. Therefore, you should always quote
character classes that are meant as arguments to a program.
HTH
Erik
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#13295
; Package
coreutils
.
(Fri, 28 Dec 2012 23:51:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 13295 <at> debbugs.gnu.org (full text, mbox):
Thanks Erik. That does help.
Randy
-----Original Message-----
From: Erik Auerswald [mailto:auerswal <at> unix-ag.uni-kl.de]
Sent: Friday, December 28, 2012 3:47 PM
To: Killen, Randy; 13295 <at> debbugs.gnu.org
Subject: Re: bug#13295: Possible bug - tr utility
Hi Randy,
On 12/28/2012 06:37 PM, Killen, Randy wrote:
> Hello -
>
> I encountered the situation shown below so thought that I would report it to see if it might be a bug or is expected behavior. Please let me know if you need additional information.
>
> Randy
>
>
> $
> $ echo something | tr [:lower:] [:upper:] SOMETHING $ echo something |
> tr '[:lower:]' '[:upper:]'
> SOMETHING
> $
> $ touch l
> $ echo something | tr [:lower:] [:upper:]
> tr: misaligned [:upper:] and/or [:lower:] construct $ echo something |
> tr '[:lower:]' '[:upper:]'
> SOMETHING
> $ rm l
> $
> $ touch u
> $ echo something | tr [:lower:] [:upper:]
> tr: misaligned [:upper:] and/or [:lower:] construct $ echo something |
> tr '[:lower:]' '[:upper:]'
> SOMETHING
> $ rm u
> $
> $ touch l
> $ touch u
> $ echo something | tr [:lower:] [:upper:] something $ echo something |
> tr '[:lower:]' '[:upper:]'
> SOMETHING
> $ rm l
> $ rm u
This is expected behavior, caused by lack of quoting that results in the shell (Bash) interpreting [...] as a wildcard pattern for file name globbing (see glob(7)). If the 'nullglob' option of the shell is disabled (use 'shopt nullglob' to display the current setting), a wildcard that matches no files is kept as is. Thus the wildcards [:lower:] and [:upper:] are either replaced by l resp. u if one of those files exist or kept, if no matching file exists.
Quoting the special characters '[' and ']' by using '[:lower:]' resp.
'[:upper:]' (including the quotes) inhibits the shell from interpreting them as file globbing wildcards. Therefore, you should always quote character classes that are meant as arguments to a program.
HTH
Erik
Notice: All email and instant messages (including attachments) sent to
or from Franklin Templeton Investments (FTI) personnel may be retained,
monitored and/or reviewed by FTI and its agents, or authorized
law enforcement personnel, without further notice or consent.
Reply sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
You have taken responsibility.
(Sat, 29 Dec 2012 08:27:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
"Killen, Randy" <rkillen <at> frk.com>
:
bug acknowledged by developer.
(Sat, 29 Dec 2012 08:27:03 GMT)
Full text and
rfc822 format available.
Message #16 received at 13295-done <at> debbugs.gnu.org (full text, mbox):
Closing the bug, then....
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 26 Jan 2013 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 151 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.