Re: more splitting

Bart Schaefer <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <CAH+w=7ZVXqSn4arksNCV8sT_85zPw5vuA-1hGFYBzuq6pVPmng__45973.7965183862$1776233745$gmane$org@mail.gmail.com>
On Tue, Apr 14, 2026 at 6:54 PM Ray Andrews <[email protected]> wrote:
>
> On 2026-04-14 16:24, Philippe Altherr wrote:
> >
> > Below is a version where both, 'hex $var' and 'print -rN $var |
> > hex', produce the same result. It expects the stdin to contain strings
> > separated by NUL characters. That's why the print call has to use the
> > -N option to join its arguments with NUL characters instead of spaces.
> Your version seems good but I'm still trying to understand exactly
> what's going on.  Split on nuls you say. [...]  But, if it's split on
> nuls, where are they? [...] Or ... have you
> cleverly managed to add them and then remove them, leaving the data
> exactly as found?

They were removed by ${(0)...}.  I said "You can add things to the
stream that can later be interpreted as semantics, but then you also
have to provide the interpreter."  In Philippe's implementation,
"print -rN" adds NULs, and ${(0)...} is the interpreter that uses them
as semantics and therefore removes them again.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.