zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: priority problem of ":|" and ":*"
Date: Wed, 26 Dec 2012 22:24:58 -0800	[thread overview]
Message-ID: <121226222458.ZM735@torch.brasslantern.com> (raw)
In-Reply-To: <20121226100944.GB8145@localhost.localdomain>

On Dec 26,  6:09pm, Han Pingtian wrote:
} Subject: Re: priority problem of ":|" and ":*"
}
} On Wed, Dec 26, 2012 at 01:10:19AM -0800, Bart Schaefer wrote:
} > And in fact poring through the code it appears that rule 5 double-quoted
} > joining is explicitly SKIPPED when the length is requested:
}
} 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
} ?

Unfortunately you can't think of the parameter flags and modifiers like
arithmetic operators.  They don't have well-defined precedences.  So it
is almost meaningless to speak of # or :| having relative "priority."
The numbering of the "rules" for parameter expansion in the manual
describes the order in which operations are applied, and sometimes the
rules do not cover all possible combinations.

Those "rules" were derived after the fact by code examination, not made
up ahead of time as a specification for how the code is suppose to work.
In situations where the code and the manual disagree, code is definitive
unless we are able to determine that (a) the description in the manual
is more sensible and (b) nothing is going to break if we revise the code
to match the documentation.  I don't believe we've established (b) here.

In this case rule 5 should have mentioned an exception for the # length
expression as it does for the (@) array flag, and the description of SPEC
in the ${#SPEC} documentation might have been qualified to explain that
surrounding double-quotes are intentionally prevented from altering the
semantics of the length calculation.

To get what you expected, you must use a nested substitution.


  reply	other threads:[~2012-12-27  6:25 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
2012-12-27  6:24       ` Bart Schaefer [this message]
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=121226222458.ZM735@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).