zsh-users
 help / color / mirror / code / Atom feed
From: "Daniel Shahaf" <d.s@daniel.shahaf.name>
To: "Zsh Users" <zsh-users@zsh.org>
Subject: Re: auto-quoting inside braces in arguments
Date: Fri, 19 Feb 2021 16:50:18 +0000	[thread overview]
Message-ID: <bc5479d9-1a02-451d-a8fc-3ffd37bedb4e@www.fastmail.com> (raw)
In-Reply-To: <20210219161010.GB7102@tarpaulin.shahaf.local2>

Daniel Shahaf wrote on Fri, 19 Feb 2021 16:10 +00:00:
> Bart Schaefer wrote on Thu, Feb 18, 2021 at 14:44:29 -0800:
> > On Thu, Feb 18, 2021 at 2:13 PM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > >
> > > Hang on.  Why would it matter which style of quotes would have been
> > > used?
> > 
> > In your example, what if $foo and $baz have an opening and closing
> > quote in their values?

By the way, the scenario you're implying is this:
.
    eval ${:-'"one'}${(qq):-two}${:-'three"'}
.
where (qq) was deliberately used so as not to interact with the literal
double-quote marks already in the value.

This sort of construct means there are _two_ levels of parsing that are
going to happen — one for each type of quotes (for instance, two
«eval»s, or an «eval» that runs «sh -c») — and therefore, $two should be
quoted twice, as in «zsh -c 'eval '${(q)${(q)lorem}» (where the outer
(q) is only correct because the command name happens to be «zsh»).

> As I wrote in the part you'd snipped:
> 
> > > > normally $foo would be constructed to end on inter-token whitespace,
> 
> It's of course possible to write code where the number of q's in bar matters
> (for instance, «eval ${:-\$}${(q…):-lorem}»), but that falls under "don't do
> that".


  reply	other threads:[~2021-02-19 16:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-18 13:40 Vincent Lefevre
2021-02-18 17:35 ` Daniel Shahaf
2021-02-18 18:30   ` Bart Schaefer
2021-02-18 18:52     ` Bart Schaefer
2021-02-19 12:24       ` Vincent Lefevre
2021-02-18 18:57     ` Ray Andrews
2021-02-18 19:07       ` Bart Schaefer
2021-02-18 21:49         ` Ray Andrews
2021-02-18 22:12         ` Daniel Shahaf
2021-02-18 22:44           ` Bart Schaefer
2021-02-19 16:10             ` Daniel Shahaf
2021-02-19 16:50               ` Daniel Shahaf [this message]
2021-02-19 21:53                 ` Bart Schaefer
2021-02-19 12:17     ` Vincent Lefevre
2021-02-19 12:29       ` Vincent Lefevre
2021-02-19 22:15         ` Bart Schaefer

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=bc5479d9-1a02-451d-a8fc-3ffd37bedb4e@www.fastmail.com \
    --to=d.s@daniel.shahaf.name \
    --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).