Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
print -C and terminators
- X-seq: zsh-workers 47890
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Cc: Beverly Pope <countryone77@xxxxxxxxx>, Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Subject: print -C and terminators
- Date: Sat, 30 Jan 2021 10:51:58 -0800
- Archived-at: <https://zsh.org/workers/47890>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2021-01/CAH%2Bw%3D7atW1ArhSO0QLux_XxXR4NBmytZwZ5b79j-2CSv%2BTajpg%40mail.gmail.com>
- In-reply-to: <0421713D-25C5-477A-90AD-C0BD2B40EED2@gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <d611ab66-c6f9-655f-89dc-ded8697fe0ed@eastlink.ca> <CAN=4vMp+JykOWEYQ5qO495-hOpQXh+4RN6iHcYTP-APg8XHESQ@mail.gmail.com> <CAH+w=7bN7miEudLZcLknDQH3im=u8CCe_3GUqtEJMtyidV8bUg@mail.gmail.com> <CAN=4vMop86hkyYMaBkF-tJaVRaN5Z28gJLqL9tSdy-uy1DNMgg@mail.gmail.com> <0421713D-25C5-477A-90AD-C0BD2B40EED2@gmail.com>
On Sat, Jan 30, 2021 at 7:00 AM Beverly Pope <countryone77@xxxxxxxxx> wrote:
>
> On Jan 30, 2021, at 4:50 AM, Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
>
> > print -rC1 --
> >
> > This command doesn't print anything.
>
> % print -rC1 -- no_such_file(N)
>
> zsh 5.8 (Ubuntu): prints nothing
> zsh 5.7.1 (Mac): prints return
Hm; I get no output, in both cases. Similarly on Centos (zsh 5.0).
This behavior seems like a bug to me. Neither -n nor -N were
specified, so "print" should always output at least a newline.
However, it's been around for quite some time and obviously some
people know about it, so I suppose it should just be documented. The
doc does make a very oblique reference to it under the -N option:
print -rNC1 -- "$list[@]" is a canonical way to print an
arbitrary list as null-delimited records.
The implication is that -C prevents the terminating NUL byte from
being printed when $list is empty.
ubuntu% print -rN -- | od -c
0000000 \0
0000001
ubuntu% print -rN -- 1 2 3 | od -c
0000000 1 \0 2 \0 3 \0
0000006
ubuntu% print -rNC1 -- | od -c
0000000
ubuntu% print -rNC1 -- 1 2 3 | od -c
0000000 1 \0 2 \0 3 \0
0000006
The related behavior of -n is a bit weird:
ubuntu% print -rnN -- | od -c
0000000
ubuntu% print -rnN -- 1 2 3 | od -c
0000000 1 \0 2 \0 3
0000005
This, however, is more questionable:
ubuntu% print -raNC1 -- 1 2 3 | od -c
0000000 1 \0 2 \0 3 \0
0000011
This explains the trailing spaces on the test case for globbing that I
posted a few days ago. I sort of get why -a needs to do that when
the column count is >1, but it shouldn't be inserting trailing spaces
when the column count is 1.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author