zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Cc: Beverly Pope <countryone77@gmail.com>,
	Roman Perepelitsa <roman.perepelitsa@gmail.com>
Subject: print -C and terminators
Date: Sat, 30 Jan 2021 10:51:58 -0800	[thread overview]
Message-ID: <CAH+w=7atW1ArhSO0QLux_XxXR4NBmytZwZ5b79j-2CSv+Tajpg@mail.gmail.com> (raw)
In-Reply-To: <0421713D-25C5-477A-90AD-C0BD2B40EED2@gmail.com>

On Sat, Jan 30, 2021 at 7:00 AM Beverly Pope <countryone77@gmail.com> wrote:
>
> On Jan 30, 2021, at 4:50 AM, Roman Perepelitsa <roman.perepelitsa@gmail.com> 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.


       reply	other threads:[~2021-01-30 18:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <d611ab66-c6f9-655f-89dc-ded8697fe0ed@eastlink.ca>
     [not found] ` <CAN=4vMp+JykOWEYQ5qO495-hOpQXh+4RN6iHcYTP-APg8XHESQ@mail.gmail.com>
     [not found]   ` <CAH+w=7bN7miEudLZcLknDQH3im=u8CCe_3GUqtEJMtyidV8bUg@mail.gmail.com>
     [not found]     ` <CAN=4vMop86hkyYMaBkF-tJaVRaN5Z28gJLqL9tSdy-uy1DNMgg@mail.gmail.com>
     [not found]       ` <0421713D-25C5-477A-90AD-C0BD2B40EED2@gmail.com>
2021-01-30 18:51         ` Bart Schaefer [this message]
2021-01-30 19:08           ` Beverly Pope
2021-01-30 22:47           ` Roman Perepelitsa
2021-01-31  1:08             ` Bart Schaefer
2021-01-31  9:36               ` Stephane Chazelas
2021-01-31 21:12                 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7atW1ArhSO0QLux_XxXR4NBmytZwZ5b79j-2CSv+Tajpg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=countryone77@gmail.com \
    --cc=roman.perepelitsa@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).