From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22172 invoked by alias); 11 Oct 2014 00:48:40 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33428 Received: (qmail 17726 invoked from network); 11 Oct 2014 00:48:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.2 Date: Sat, 11 Oct 2014 08:38:17 +0800 From: Han Pingtian To: zsh-workers@zsh.org Subject: Re: (s) splitting - is there any way to provide "dynamic" separator Message-ID: <20141011003817.GA2786@localhost.localdomain> Mail-Followup-To: zsh-workers@zsh.org References: <5436A310.7040101@gmail.com> <141009184525.ZM29875@torch.brasslantern.com> <5437856D.3050700@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5437856D.3050700@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14101100-0005-0000-0000-0000058E8873 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 ?