Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Is outer quoting not needed (docs say "redundant")?
- X-seq: zsh-users 23004
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Is outer quoting not needed (docs say "redundant")?
- Date: Tue, 12 Dec 2017 15:00:24 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20171212150028euoutp01ff0dd7d0e87a02ad529b114a37dc2f48~-lBdp2Cuj0800208002euoutp01N
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1513090828; bh=CV7kZDXNFOmml7aFUxXiHC2j52wSeLTAoXVHKOxht5k=; h=Date:From:To:Subject:In-reply-to:References:From; b=FmD++eVtY/CoFuQCayH94oEdIet//1eU0I5oUhXA1vbr4SHR3bDLsXj32DNEWBDhg 4HDJbIzJpDSr7iuWxH3eisf15WZ3fkK6yIEjvxE1S2e581Wxiho2R+imXtr2fyFXWh g/WwMhpVEK22KHRwsHPGb5i5RaPDf8BudnNJbihU=
- In-reply-to: <etPan.5a2fdc87.88f1eab.c73c@zdharma.org>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <CGME20171212135535epcas4p2456a2aed9c9be07c9d461acb602b71e9@epcas4p2.samsung.com> <etPan.5a2fdc87.88f1eab.c73c@zdharma.org>
On Tue, 12 Dec 2017 14:41:26 +0100
Sebastian Gniazdowski <psprint@xxxxxxxxxxx> wrote:
> manual says:
> "in "${(@f)"$(foo)"}", there are two sets of quotes, one
> surrounding the whole expression, the other (redundant) surrounding
> the $(foo) as before."
>
> One user reported that single, outer quoting always worked for
> him. Word "redundant" quite confirms this, but can we be sure?
The quoting is done at an early stage, by the lexical analyser. Double
quotes are handled as a special form of analysis (function
dquote_parse()) ensuring that
- everything in the quotes is marked as being within the quotes;
- in particular, "$" are tokenised differently compared with "$"
outside double quotes, so the parameter substitution behaves
correctly;
- ${ ... } expressions must complete before the end of the quotes --- so
double quotes internally are noted as tokens but don't affect the top
level parsing.
The internal double quotes show up as part of the argument of the
parameter substitution because they're not removed until we've analysed
the substitution. So if necessary they will flag up the fact that the
internal expression is double quoted. But because the parameter
substitution in this case is already double quoted, they have no
additional effect.
There may be a better example to use in the manual: the example here
uses the "@" flag for splitting, which is only meaningful if the outer
quotes are present. But it does have the use of pointing out that
the double quotes are nested --- which might not be obvious, you
might naively think the "${" and "}" were in two different
double-quoted expressions.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author