GNU bug report logs -
#29421
bug in command "tr"
Previous Next
Reported by: wangjian <halfmoonhalf <at> gmail.com>
Date: Fri, 24 Nov 2017 02:19:01 UTC
Severity: normal
Tags: notabug
Done: Pádraig Brady <P <at> draigBrady.com>
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 29421 in the body.
You can then email your comments to 29421 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#29421
; Package
coreutils
.
(Fri, 24 Nov 2017 02:19:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
wangjian <halfmoonhalf <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Fri, 24 Nov 2017 02:19:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi there, I think this is a bug
mkdir empty_foler
cd empty_foler
touch a
echo "abc" | tr [:blank:] + # you will get “+bc” as output, instead of “abc”
touch b
echo "abc" | tr [:blank:] # you will get “bbc” as output, instead of “abc”
My system info:
CentOS release 6.7 (Final)
linux kernel version 2.6.32-573.el6.x86_64
$ tr --version
tr (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jim Meyering.
[wangjian <at> kvmhost73 temp]$
Wang
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#29421
; Package
coreutils
.
(Fri, 24 Nov 2017 02:32:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 29421 <at> debbugs.gnu.org (full text, mbox):
tag 29421 notabug
close 29421
stop
On 23/11/17 17:01, wangjian wrote:
> Hi there, I think this is a bug
>
> mkdir empty_foler
> cd empty_foler
> touch a
> echo "abc" | tr [:blank:] + # you will get “+bc” as output, instead of “abc”
> touch b
> echo "abc" | tr [:blank:] # you will get “bbc” as output, instead of “abc”
>
> My system info:
> CentOS release 6.7 (Final)
> linux kernel version 2.6.32-573.el6.x86_64
You must have a file called "a" in the current directory.
You'll need to quote so the shell doesn't change it on you.
I.E:
echo "a bc" | tr '[:blank:]' +
a+bc
cheers,
Pádraig
Added tag(s) notabug.
Request was from
Pádraig Brady <P <at> draigBrady.com>
to
control <at> debbugs.gnu.org
.
(Fri, 24 Nov 2017 02:32:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
29421 <at> debbugs.gnu.org and wangjian <halfmoonhalf <at> gmail.com>
Request was from
Pádraig Brady <P <at> draigBrady.com>
to
control <at> debbugs.gnu.org
.
(Fri, 24 Nov 2017 02:32:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#29421
; Package
coreutils
.
(Fri, 24 Nov 2017 02:35:01 GMT)
Full text and
rfc822 format available.
Message #15 received at 29421 <at> debbugs.gnu.org (full text, mbox):
tag 29421 notabug
close 29421
stop
Hello,
On Thu, Nov 23, 2017 at 6:01 PM, wangjian <halfmoonhalf <at> gmail.com> wrote:
> Hi there, I think this is a bug
>
> mkdir empty_foler
> cd empty_foler
> touch a
> echo "abc" | tr [:blank:] + # you will get “+bc” as output, instead of “abc”
> touch b
> echo "abc" | tr [:blank:] # you will get “bbc” as output, instead of “abc”
This is not a bug, simply incorrect usage of the parameters on the shell.
Your shell (e.g. bash) expands unquoted [:blank:] to match ANY
file with names matching a/b/l/n/k , and replaces them on the commandline
BEFORE executing 'tr'.
Only if no files match a/b/l/n/k, then the string '[:blank:]' is
passed on to tr as-is.
Observe the following (in an empty directory):
$ echo [:blank:]
[:blank:]
$ touch a
$ echo [:blank:]
a
$ touch b
$ echo [:blank:]
a b
As opposed to using quotes:
$ echo "[:blank:]"
[:blank:]
And so, once you created the files a and b,
the command you executed was equivalent to
echo abc | tr a b
which indeed results in "bbc".
To avoid such issues, always quote the parameters to 'tr'.
regards,
- assaf
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#29421
; Package
coreutils
.
(Fri, 24 Nov 2017 06:15:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 29421 <at> debbugs.gnu.org (full text, mbox):
Thanks for your quick response! That was really fantastic and impressive!
> On 24 Nov 2017, at 10:34 am, Assaf Gordon <assafgordon <at> gmail.com> wrote:
>
> tag 29421 notabug
> close 29421
> stop
>
> Hello,
>
> On Thu, Nov 23, 2017 at 6:01 PM, wangjian <halfmoonhalf <at> gmail.com> wrote:
>> Hi there, I think this is a bug
>>
>> mkdir empty_foler
>> cd empty_foler
>> touch a
>> echo "abc" | tr [:blank:] + # you will get “+bc” as output, instead of “abc”
>> touch b
>> echo "abc" | tr [:blank:] # you will get “bbc” as output, instead of “abc”
>
> This is not a bug, simply incorrect usage of the parameters on the shell.
> Your shell (e.g. bash) expands unquoted [:blank:] to match ANY
> file with names matching a/b/l/n/k , and replaces them on the commandline
> BEFORE executing 'tr'.
> Only if no files match a/b/l/n/k, then the string '[:blank:]' is
> passed on to tr as-is.
>
> Observe the following (in an empty directory):
>
> $ echo [:blank:]
> [:blank:]
>
> $ touch a
> $ echo [:blank:]
> a
>
> $ touch b
> $ echo [:blank:]
> a b
>
> As opposed to using quotes:
>
> $ echo "[:blank:]"
> [:blank:]
>
>
> And so, once you created the files a and b,
> the command you executed was equivalent to
> echo abc | tr a b
> which indeed results in "bbc".
>
> To avoid such issues, always quote the parameters to 'tr'.
>
> regards,
> - assaf
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 22 Dec 2017 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 242 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.