Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: print -C and terminators



2021-01-30 17:08:21 -0800, Bart Schaefer:
> On Sat, Jan 30, 2021 at 2:47 PM Roman Perepelitsa
> <roman.perepelitsa@xxxxxxxxx> wrote:
> >
> > I learned about it from the documentation for print:
> 
> The paragraph about the "-l" option seems like an odd place for the
> only mention of this, but the zsh doc is like that a lot.
> 
> > I don't think I ever wrote or saw code where -l is correct and -C1 is wrong.
> 
> With the exception of those doc examples, I don't think I ever saw or
> wrote code where the argument to -C was less than two (unless it was a
> variable).  Oh, well.
[...]

I have always been annoyed at that behaviour of print -rl -
outputting an empty line when not being given any argument (and
print -f '%s\n' -- has the same problem).

Until I saw someone on unix.stackexchange.com use print -rC1 --
which addresses the problem. I was the one suggesting it be more
explicitly documented at
https://www.zsh.org/mla/workers/2019/msg01202.html
Since then, I've replaced all my (broken) usages of print -rl
with print -rC1.

I agree it wouldn't harm to also clarify in the -C documentation
that nothing is output if no argument is given.

This:

~$ print -raC2 a b c | sed -n l
a  b  $
c  $

(
~$ print -rC2 a b c | sed -n l
a  c$
b$
)

could also be improved.

-- 
Stephane




Messages sorted by: Reverse Date, Date, Thread, Author