zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Re: PATCH: improve ${(q)...}
Date: Tue, 28 Apr 2009 15:37:49 -0700	[thread overview]
Message-ID: <090428153749.ZM8596@torch.brasslantern.com> (raw)
In-Reply-To: <5191.1240937187@csr.com>

On Apr 28,  5:46pm, Peter Stephenson wrote:
}
} It's annoyed me for a while now that single-quoting a value uses
} single quotes even where they're not needed, and with existing single
} quotes in the value at the start or end you get something quite messy.

Hmm.

} This fixes the problem.  Is there a good reason for making this a
} different flag, or is altering (q) good enough?  I couldn't think of a
} reason why you would need it to be verbose

The proposed patch changes the behavior of nested (q) options rather
significantly.  E.g., ${(qqq)${(qq)v}} becomes very different.  This
could be important if the resulting string is going to be processed
with "eval".

Also keep in mind what happens when strings are catenated by adjacency.

x=\$foo
y=bar
foo=this
foobar=that
eval print ${x}${(qq)y}

Would you really expect "that" rather than "thisbar"?  (Admittedly an
edge case.)

Although it's true that we never "guaranteed" the quoting behavior,
it's implicit in the doc:

       ... If this flag is given twice, the resulting words
       are quoted in single quotes and if it is given three times,
       the words are quoted in double quotes ...

Note it *doesn't* say "as if in <mumble> quotes".  Wrapping the entire
string is also consistent with (qqqq), which is distinct from (q) which
applies $'...' only where needed.


  reply	other threads:[~2009-04-28 22:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-28 16:46 Peter Stephenson
2009-04-28 22:37 ` Bart Schaefer [this message]
2009-04-29  8:51   ` Peter Stephenson
2009-04-29 16:35     ` Bart Schaefer
2009-04-29 16:42       ` Peter Stephenson

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=090428153749.ZM8596@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.dk \
    /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).