[11247] in Athena Bugs
decmips 7.6G: tr
daemon@ATHENA.MIT.EDU (cfields@MIT.EDU)
Thu Oct 21 20:21:00 1993
From: cfields@MIT.EDU
Date: Thu, 21 Oct 93 20:20:39 EDT
To: Petr Adamek <adamek@MIT.EDU>, bugs@MIT.EDU
Cc:
Hello! You reported a bug in tr on the DECstation:
> I type:
> %tr -s x
> abcdxxxefgh
> ^D
> and output is:
> abcdefgh
>
>What should have happened:
>
> while it should be:
> abcdxefgh
This is not really true. The manual page says:
Syntax
tr [-cds] [string1[string2]]
-s squeezes all strings of repeated output characters that are
in string2 to single characters.
In your example, tr -s x, you did not specify a string2 - only a string1.
However,
tr -s "" x
would do what you want in this example, as it specifies x in string2 (and
an empty string as a placeholder for string1).
What tr does in the case of an unspecified string2 is not defined in the
manual page. On the DECstation, it is assumed that string2 is "". (Other
platforms vary.) Thus tr -s x is really equivalent to tr -s x "" which
means both of:
(a.) Substitute nothing ("") for all occurrences of x (which is
what you see).
(b.) Take all multiple instances of nothing ("") and compress
them to a single instance of nothing, which arguably,
is happening.
If you have any further questions on this, let me know. I will otherwise
close this report. Thank you for your bug report.
Craig