Re: more splitting
Bart Schaefer <[email protected]> Tue, 14 Apr 2026 23:14:51 -0700
| Newsgroups | gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CAH+w=7ZVXqSn4arksNCV8sT_85zPw5vuA-1hGFYBzuq6pVPmng@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.