From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29120 invoked by alias); 26 Dec 2012 11:24:10 -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: 17498 Received: (qmail 17580 invoked from network); 26 Dec 2012 11:24:08 -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 Received-SPF: none (ns1.primenet.com.au: domain at linux.vnet.ibm.com does not designate permitted sender hosts) Date: Wed, 26 Dec 2012 18:09:44 +0800 From: Han Pingtian To: zsh-users@zsh.org Subject: Re: priority problem of ":|" and ":*" Message-ID: <20121226100944.GB8145@localhost.localdomain> References: <20121224105241.GA24051@localhost.localdomain> <20121225231133.GA8145@localhost.localdomain> <121226011019.ZM32249@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <121226011019.ZM32249@torch.brasslantern.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12122610-9360-0000-0000-00000E5F56DC On Wed, Dec 26, 2012 at 01:10:19AM -0800, Bart Schaefer wrote: > 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. > But I think ":|" doesn't skip the double-quoted, so the "#" would get the length of the result of ":|", because "#"'s priority is lower than ":|"'s. Or when running in double-quoted, "#" will has a higher priority ? % a1=(a b c);a2=('a b c');print ${#a1:|a2} 3 % a1=(a b c);a2=('a b c');print "${a1:|a2}" % a1=(a b c);a2=('a b c');print "${#a1:|a2}" 3 Looks like #'s priority will be higher than :| in the double-quoted.