GNU bug report logs -
#24054
tr bug? [:space:] acts like "a"
Previous Next
Reported by: <pmun <at> tutanota.de>
Date: Fri, 22 Jul 2016 20:20: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 24054 in the body.
You can then email your comments to 24054 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#24054
; Package
coreutils
.
(Fri, 22 Jul 2016 20:20:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
<pmun <at> tutanota.de>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Fri, 22 Jul 2016 20:20:02 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)]
For the last few weeks tr [:space:] isn't working the way it used to for me under Ubuntu 14.04. Instead of acting on spaces it acts on "a"s.:
me <at> U:~$ echo "thisstring abcde what the heck?" | tr [:space:] '_'
thisstring _bcde wh_t the heck?
me <at> U:~$
This is 64 bit 14.04 built up from the mini.iso with just plain Openbox as the only DE, in lxterminal using bash.
--
Securely sent with Tutanota. Claim your encrypted mailbox today!
https://tutanota.com
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#24054
; Package
coreutils
.
(Fri, 22 Jul 2016 21:19:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 24054 <at> debbugs.gnu.org (full text, mbox):
tag 24054 notabug
close 24045
stop
Hello,
On 07/22/2016 02:58 PM, pmun <at> tutanota.de wrote:
> For the last few weeks tr [:space:] isn't working the way it used to for me under Ubuntu 14.04. Instead of acting on spaces it acts on "a"s.:
>
> me <at> U:~$ echo "thisstring abcde what the heck?" | tr [:space:] '_'
> thisstring _bcde wh_t the heck?
>
> This is 64 bit 14.04 built up from the mini.iso with just plain Openbox as the only DE, in lxterminal using bash.
This is not a bug, but a result of your shell (bash) performing filename completion on single-letter filenames in your current directory.
In bash, the syntax [X] without quotes does filename completion, just like "*" or "?".
I would guess that in the last few weeks you created a file called 'a' in the directory,
and so '[:space:]' matched it (technically it means: match filenames of one character, one of :,s,p,a,c or e).
It used to "just work", because if the shell does not find matching files, it passes the parameter as-is to the program.
The following will demonstrate:
$ mkdir empty
$ cd empty
$ echo [:space:]
[:space:]
$ touch a
$ echo [:space:]
a
$ touch ':'
$ echo [:space:]
: a
$ echo '[:space:]'
[:space:]
Since the shell replaced '[:space:]' with 'a', the 'tr' command became:
tr a '_'
which is the behavior you encountered.
The solution is to always quote such parameters:
$ echo "thisstring abcde what the heck?" | tr '[:space:]' '_'
thisstring_abcde_what_the_heck?_
(The last underscore is the newline, which also counts as whitespace).
To learn more about bash's filename expansion capabilities, see here:
https://www.gnu.org/software/bash/manual/bashref.html#Filename-Expansion
As such I'm closing this bug report, but discussion can continue by replying to this thread.
regards,
- assaf
Added tag(s) notabug.
Request was from
Pádraig Brady <P <at> draigBrady.com>
to
control <at> debbugs.gnu.org
.
(Fri, 22 Jul 2016 23:01:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
24054 <at> debbugs.gnu.org and <pmun <at> tutanota.de>
Request was from
Pádraig Brady <P <at> draigBrady.com>
to
control <at> debbugs.gnu.org
.
(Fri, 22 Jul 2016 23:01:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#24054
; Package
coreutils
.
(Sat, 23 Jul 2016 18:25:01 GMT)
Full text and
rfc822 format available.
Message #15 received at 24054 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Yep, that fixed it. I tested [:print:] and it works like that also. I presume this applies to ALL the bracketed special expressions mentioned in man tr. If anyone knows differently, please correct me. I'm surprised I haven't bashed into this pitfall sooner.
Thanks, Mr. Gordon, for replying in a flash.
[Message part 2 (text/html, inline)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 21 Aug 2016 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 297 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.