From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26940 invoked from network); 13 Jan 2009 22:08:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Jan 2009 22:08:43 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 95510 invoked from network); 13 Jan 2009 22:08:35 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Jan 2009 22:08:35 -0000 Received: (qmail 25000 invoked by alias); 13 Jan 2009 22:08:30 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26306 Received: (qmail 24990 invoked from network); 13 Jan 2009 22:08:30 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 13 Jan 2009 22:08:30 -0000 Received: from mtaout02-winn.ispmail.ntl.com (mtaout02-winn.ispmail.ntl.com [81.103.221.48]) by bifrost.dotsrc.org (Postfix) with ESMTP id 3212580293E7 for ; Tue, 13 Jan 2009 23:08:23 +0100 (CET) Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20090113220818.FVKC4080.mtaout02-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com> for ; Tue, 13 Jan 2009 22:08:18 +0000 Received: from pws-pc ([81.107.45.176]) by aamtaout03-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20090113220818.GLEH2093.aamtaout03-winn.ispmail.ntl.com@pws-pc> for ; Tue, 13 Jan 2009 22:08:18 +0000 Date: Tue, 13 Jan 2009 22:08:10 +0000 From: Peter Stephenson To: Zsh list Subject: Re: treatment of empty strings - why is this not a bug? Message-ID: <20090113220810.5ee564eb@pws-pc> In-Reply-To: <20090113192409.0c21909a@pws-pc> References: <18796.17298.94642.461735@gargle.gargle.HOWL> <20090113192409.0c21909a@pws-pc> X-Mailer: Claws Mail 3.6.1 (GTK+ 2.14.5; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.0 c=1 a=b9lWrR2ZfKoA:10 a=7862LJqnZcQA:10 a=NLZqzBF-AAAA:8 a=fdjTrTskFa-p_otRhXsA:9 a=4iZWpWkDkw7xDCThqZ0vSnpPIUgA:4 a=LY0hPdMaydYA:10 X-Virus-Scanned: ClamAV 0.92.1/8861/Tue Jan 13 17:09:19 2009 on bifrost X-Virus-Status: Clean On Tue, 13 Jan 2009 19:24:09 +0000 Peter Stephenson wrote: > On Tue, 13 Jan 2009 02:32:34 -0500 > Greg Klanderman wrote: > > lwm% x=::: && for v in "${(s-:-)x}" ; do echo "v= =>$v<=" ; done > > v= =><= > > v= =><= > > Hmm... > > % setopt rcexpandparam > % x=::: && for v in "${(s-:-)x}" ; do echo "v= =>$v<=" ; done > v= =><= > v= =><= > v= =><= > v= =><= > > What's this got to do with RC_EXPAND_PARAM and why is the behaviour > without that option not a bug? Er... I'm very glad you asked. > > -- > Peter Stephenson > Web page now at http://homepage.ntlworld.com/p.w.stephenson/ Oh, yes. I had to look at the code before the answer came to me, again---I've run up against this one several times before. It's not a bug because it's documented to do something incredibly pointless: For historical reasons, the usual behaviour that empty array elements are retained inside double quotes is disabled for arrays generated by splitting; hence the following: example(line="one::three" print -l "${(s.:.)line}") produces two lines of output for tt(one) and tt(three) and elides the empty field. To override this behaviour, supply the "(@)" flag as well, i.e. tt("${(@s.:.)line}"). Not sure why RC_EXPAND_PARAM makes it work more sensibly, however. -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/