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

Re: (0) not working ?



It appears that you need the “p” flag for the join and probably for the split as well.

Also, @ says “In  double  quotes,  array  elements  are put into separate words.”
But you don’t have double quotes so the @ isn’t needed.

% var1=( a b c d )   
% var2=${(j:\0:)var1}
% print $#var2
10

At this point var2 is a scaler with two characters ‘\’ and ‘0’ separating what were the words.

% var3=${(pj:\0:)var1}
% print $#var3
7

This is what you are expecting / needing

% print -l ${(0)var3}
a
b
c
d

The print works

% print -l ${(@0)var3}
a
b
c
d


The @ isn’t needed

(Again… I’m new here so please verify everything)

On Nov 27, 2019, at 8:18 AM, Marc Chantreux <eiro@xxxxxxxxx> wrote:

hello Perry,

I’m very new here so take what I say with caution but why
did you put the backslash before the 0?

if you use xxd:

   echo -n 0 $'\0'|xxd

you can see that 0 is the symbol 0x30 (48th of the ascii table)
when \0 is 00.

\0 is non-sense in a legit text stream so it can be used as
a separator instead of all those separators that can exist in
text ( "\n", ",", ":" " ", "\t").

see xargs -0, find -print0, ...

regards
marc



Attachment: smime.p7s
Description: S/MIME cryptographic signature



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