Harald Dunkel wrote:
> According to the man page
> 
>       echo 'a           b' | tr -s 'z' ' '
> 
> should return
> 
>       a           b
> 
> instead of
> 
>       a b
> 
> since there is no space character in set1, but just a 'z'.

Thanks for the report.  The wording does seem to be lacking.

The man page says:

       -s, --squeeze-repeats
              replace each input sequence of a repeated character that
              is listed in SET1 with a single occurrence of that
              character

That does seem insufficient.  It only talks about SET1 and doesn't
mention the behavior when SET2 is included.

Later in the man page it says:

       -s uses SET1 if not translating nor deleting; else squeezing
       uses SET2 and occurs after translation or deletion.

The man page is created from the --help output.  Both the --help
output and the man page need to be as concise as possible.

The man page also says:

       The  full  documentation  for tr is maintained as a Texinfo manual.  If
       the info and tr programs are properly installed at your site, the  com‐
       mand

              info coreutils 'tr invocation'

       should give you access to the complete manual.

This should cause you to read the info manual for the complete
documentation.  The info doc is not as constrained as the man page.

The info page says:

     The `--squeeze-repeats' option may also be used when translating, in
  which case `tr' first performs translation, then squeezes repeats from
  any remaining characters using SET2.

That info documentation section explains the behavior you are seeing.
With both SET1 and SET2 supplied then first translation is done and
then squeezing is done using SET2.

With "echo 'a           b' | tr -s 'z' ' '" you have specified that
all z characters should be translated to space characters and then
that repeated space characters should be squeezed into one space
character.

Obviously translating z chars into space chars and then squeezing z
characters wouldn't make any sense.  After translation there won't be
any z characters left to be squeezed since those were translated.
Squeezing from the first set only makes sense when only SET1 is
supplied and no translation happening.

Do you have any suggestions for improvements in the wording for the
online help from --help and therefore the man page?

Bob



--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to