From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10704 invoked by alias); 26 Dec 2012 09:10:29 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17497 Received: (qmail 8569 invoked from network); 26 Dec 2012 09:10:27 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <121226011019.ZM32249@torch.brasslantern.com> Date: Wed, 26 Dec 2012 01:10:19 -0800 In-reply-to: <20121225231133.GA8145@localhost.localdomain> Comments: In reply to Han Pingtian "Re: priority problem of ":|" and ":*"" (Dec 26, 7:11am) References: <20121224105241.GA24051@localhost.localdomain> <20121225231133.GA8145@localhost.localdomain> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: priority problem of ":|" and ":*" MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Dec 26, 7:11am, Han Pingtian wrote: } } > % a1=(a b c);a2=('a b c');print "${#a1:|a2}" } > 3 } > } > in this, the priority should be "5 Double-quoted joining" first, then "7 } > modifiers", then "9 length". So 'print "${#a1:|a2}"' should output 0 I } > think. And the ":*" has the same problem. Hmm. % a1=(a b c); print "${#a1}" :"${a1}": 3 :a b c: Plainly if length were applied after double-quoted joining, the above should print 5 rather than 3. As I'm pretty sure this hasn't changed *ever*, it must be that the documentation is wrong, not that :| has the wrong priority. And in fact poring through the code it appears that rule 5 double-quoted joining is explicitly SKIPPED when the length is requested: if (isarr) { if (nojoin) isarr = -1; if (qt && !getlen && isarr > 0) { val = sepjoin(aval, sep, 1); isarr = 0; } } "qt" there means double-quoted, but "getlen" means the "#" was seen. So when evaluating length, we do not remove arrayness. } For the ":*", we have this result: } } % a1=(a b c);a2=(a b c);print "${#a1:*a2}" } 3 This is consistent with the above. I admit that this is not intuitive when applying operations to the members of the array, but it's the way #, ##, %, %%, and :# have always worked, so it's a bit late to change it and arguably worse to make it different for :| and :*. (My sympathies if anyone's mail reader is too clever by half and renders a lot of that as emoticons.)