From: Han Pingtian <hanpt@linux.vnet.ibm.com>
To: zsh-users@zsh.org
Subject: Re: priority problem of ":|" and ":*"
Date: Wed, 26 Dec 2012 18:09:44 +0800 [thread overview]
Message-ID: <20121226100944.GB8145@localhost.localdomain> (raw)
In-Reply-To: <121226011019.ZM32249@torch.brasslantern.com>
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.
next prev parent reply other threads:[~2012-12-26 11:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-24 10:52 Han Pingtian
2012-12-25 23:11 ` Han Pingtian
2012-12-26 9:10 ` Bart Schaefer
2012-12-26 10:09 ` Han Pingtian [this message]
2012-12-27 6:24 ` Bart Schaefer
2012-12-27 9:06 ` Han Pingtian
2012-12-26 16:44 ` Ray Andrews
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121226100944.GB8145@localhost.localdomain \
--to=hanpt@linux.vnet.ibm.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).