Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: (s) splitting - is there any way to provide "dynamic" separator
- X-seq: zsh-workers 33416
- From: Vasiliy Ivanov <beelzebubbie.logs@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: (s) splitting - is there any way to provide "dynamic" separator
- Date: Fri, 10 Oct 2014 13:06:21 +0600
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=Cd3xXSfcnxRSmmdE+U9YBILuyiaoQGaqlmPatVbECbo=; b=dT5Wj98JahTLUShfFt08L27CPBdfQskAcoIpLQD0bWA5pr425SzBVefDoz6arPYVKA 1lZ9n1jkLxYx6zZSHD9/hfi3XMaBusUjf/m3y5k7aPQJAqVVQM6ePWEGjuZud32inGaZ 4Z8WnMef2GQGVe6qu8v5m4goT/OwjiXPjnMucS0HG5unsYgfOobM5cNtFZkPFe8+W50+ 5NVhfkKeYPyo+1M67gNLSBLfnwjvHKLRNnTDT0MPfX1BK2/PovdgS7yXBX7IFtOCrWob TOkfwajdhVNn0hSqds3p8Z1QWwAu1ibnrkR/8eJr8qu35Wp4wxwnE1uptDSHhvmxEn7f 1x5w==
- In-reply-to: <141009184525.ZM29875@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <5436A310.7040101@gmail.com> <141009184525.ZM29875@torch.brasslantern.com>
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
while
% a='11::22:33'; sep=':'; b=(${(@ps.\0.)a//$sep/$'\0'}); print $#b
3
--
Regards,
Vasiliy Ivanov <beelzebubbie.logs@xxxxxxxxx>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author