Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: (s) splitting - is there any way to provide "dynamic" separator
On Fri, Oct 10, 2014 at 01:06:21PM +0600, Vasiliy Ivanov wrote:
> On 10.10.2014 07:45, Bart Schaefer wrote:
> > On Oct 9, 9:00pm, Vasiliy Ivanov wrote:
> > }
> > } Sorry if I (maybe) missed something obvious, but I failed to find a
> > } way to use separator from parameter
> > } (e.g. a='1:2:3'; sep=':'; print -l ${(s.$sep.)a}).
> >
> > Something like this:
> >
> > print -l ${(ps.\0.)a//$sep/$'\0'}
> >
> > (Assuming there are no nul-bytes in the value of $a to begin with.)
> >
>
> Thanks, this seems more elegant than «eval» way, but I failed to understand this:
>
> % a='11::22:33'; b=("${(@s.:.)a}"); print $#b
> 4 (as expected)
>
> but (I expected same result)
>
> % a='11::22:33'; sep=':'; b=("${(@ps.\0.)a//$sep/$'\0'}"); print $#b
> 1
>
% a=11::22:33;print -l ${(ps.\0.)a//:/$'\0'}
11
22
33
% a=11::22:33;print -l "${(ps.\0.)a//:/$'\0'}"
11$''$''22$''33
%
Looks like $'\0' in double-quotes is converted to $'' and it doesn't equal
to \0 ?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author