Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: how to get verbatim output in command substitution
- X-seq: zsh-users 12728
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: how to get verbatim output in command substitution
- Date: Tue, 25 Mar 2008 21:36:48 +0000
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <080325100656.ZM9387@xxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <5fb1c7f40803250743u24479110v42bc00de2c2b22c9@xxxxxxxxxxxxxx> <20080325150126.GA4865@xxxxxxxxxxxxxxx> <080325100656.ZM9387@xxxxxxxxxxxxxxxxxxxxxx>
On Tue, Mar 25, 2008 at 10:06:56AM -0700, Bart Schaefer wrote:
> On Mar 25, 3:01pm, Stephane Chazelas wrote:
> }
> } in list contexts, command substitution is split according to the
> } $IFS special parameter.
>
> That's not quite correct. Zsh doesn't really have a concept of
> "list context" the way (say) Perl does. For practical purposes it
> has what might be called "assignment context", and everything else.
>
> If scalar assignment syntax is used, then splitting is not done and
> the resulting variable becomes scalar (even if previously declared
> as an array); otherwise splitting is done (subject to the rules of
> parameter expansion and globbing as controlled by various options).
Well, what I call "list context" (I agree it's not an official
zsh term, I kind of made it up) is anywhere expecting several
words. That can be for i in <here>, var=(<here>), cmd <here>...
Non-list contexts are for instance scalar=<here>, case <here>
in, ${var#<here>}, "<here>", $((<here>)) and so on. In those,
there's no word splitting, as of course it wouldn't make sense.
So instead of "list context", you may call it "anywhere where it
would make sense to split" if you prefer, but you get the idea...
> That's separate from the behavior of trimming trailing whitespace
> from $(...).
Yes. Though it's not whitespace, it's only NL characters (all
the NL characters even though it would have made more sense to
remove only the last one, but that's Bourne's mistake, not
zsh's)
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author