From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16337 invoked from network); 16 Jan 2009 10:02:30 -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=-1.6 required=5.0 tests=AWL,BAYES_00,WEIRD_QUOTING autolearn=no 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; 16 Jan 2009 10:02:30 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 84563 invoked from network); 16 Jan 2009 10:02:23 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 16 Jan 2009 10:02:23 -0000 Received: (qmail 19632 invoked by alias); 16 Jan 2009 10:02:17 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26320 Received: (qmail 19616 invoked from network); 16 Jan 2009 10:02:16 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 16 Jan 2009 10:02:16 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [85.115.60.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 99F8180271F0 for ; Fri, 16 Jan 2009 11:02:13 +0100 (CET) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly41d.srv.mailcontrol.com (MailControl) with ESMTP id n0GA2Aae002884 for ; Fri, 16 Jan 2009 10:02:10 GMT Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Fri, 16 Jan 2009 10:02:10 +0000 Date: Fri, 16 Jan 2009 10:02:05 +0000 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: treatment of empty strings - why is this not a bug? Message-ID: <20090116100205.4d348582@news01> In-Reply-To: <200901152029.n0FKTTHD016851@pws-pc.ntlworld.com> References: <200901152029.n0FKTTHD016851@pws-pc.ntlworld.com> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 16 Jan 2009 10:02:10.0563 (UTC) FILETIME=[7F57E530:01C977C1] X-Scanned-By: MailControl A_08_51_00 (www.mailcontrol.com) on 10.68.0.151 X-Virus-Scanned: ClamAV 0.92.1/8871/Fri Jan 16 05:16:59 2009 on bifrost X-Virus-Status: Clean On Thu, 15 Jan 2009 20:29:29 +0000 Peter Stephenson wrote: > Greg Klanderman wrote: > > I still do not understand why I get exactly two empty strings no > > matter how many colons I have in the input string: I would expect > > none based on the description you cited. > > > > phl% x=::::: && for v in "${(s-:-)x}" ; do echo "v= =>$v<=" ; done > > v= =><= > > v= =><= > > phl% x=: && for v in "${(s-:-)x}" ; do echo "v= =>$v<=" ; done > > v= =><= > > v= =><= > > It's to do with the code that joins parameters with what's next to them, > which is why the RC_EXPAND_PARAM option is different. Actually, I think I can do better than that. It's because quoted NULLs never disappear---the only things that disappear are the empty fields resulting from the splitting. You can therefore think of the key expression in the foregoing as ""${(s-:-)}"" (two double-quoted NULLs bookending an expression split into an array---this isn't how it works internally, but the effect is very similar.) Now you can see the distinction from having no quotes in the expression at all. So in the case where RC_EXPAND_PARAM is unset what remains are the NULLs at each end; with it set, those get combined with all the fields in the middle. It does have its own twisted logic. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070