zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Is outer quoting not needed (docs say "redundant")?
Date: Tue, 12 Dec 2017 15:00:24 +0000	[thread overview]
Message-ID: <20171212150024.13a1e78b@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <etPan.5a2fdc87.88f1eab.c73c@zdharma.org>

On Tue, 12 Dec 2017 14:41:26 +0100
Sebastian Gniazdowski <psprint@zdharma.org> 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


  reply	other threads:[~2017-12-12 15:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20171212135535epcas4p2456a2aed9c9be07c9d461acb602b71e9@epcas4p2.samsung.com>
2017-12-12 13:41 ` Sebastian Gniazdowski
2017-12-12 15:00   ` Peter Stephenson [this message]
2017-12-13  7:00     ` Sebastian Gniazdowski
2017-12-13 11:34       ` Peter Stephenson
2018-01-13 16:50         ` Sebastian Gniazdowski
2018-01-13 17:36           ` Bart Schaefer
     [not found]           ` <etPan.5a5a45ec.3309bd20.14e5a@AirmailxGenerated.am>
2018-01-14  4:03             ` Sebastian Gniazdowski

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=20171212150024.13a1e78b@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.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).