zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] _arguments: Escape colons and backslashes in $opt_args unambiguously.
Date: Thu, 8 Sep 2016 11:01:15 +0000	[thread overview]
Message-ID: <20160908110115.GA1707@fujitsu.shahaf.local2> (raw)
In-Reply-To: <160907171356.ZM14819@torch.brasslantern.com>

Bart Schaefer wrote on Wed, Sep 07, 2016 at 17:13:56 -0700:
> I suspect "ag" is the same thing I have installed as "ack".

"ag" and "ack" are distinct tools.

Applied both of your suggestions, and added a paragraph:

diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index b2cc392..ecf17e7 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -3949,9 +3949,7 @@ arguments.  Options are stored in the associative array
 `tt(opt_args)' with option names as keys and their arguments as
 the values.  For options that have more than one argument these are
 given as one string, separated by colons.  All colons and backslashes
-in the original arguments are preceded with backslashes.  (Note:
-Zsh 5.2 and older did not escape backslashes in the original string;
-see the tt(NEWS) file for details.)
+in the original arguments are preceded with backslashes.
 
 The parameter `tt(context)' is set when returning to the calling function
 to perform an action of the form `tt(->)var(string)'.  It is set to an
diff --git a/README b/README
index 019294e..d92fb61 100644
--- a/README
+++ b/README
@@ -91,10 +91,15 @@ equivalent of "*(1)") as well as many other forms.
 and colons in the values of option arguments when populating the $opt_args
 associative array.  Previously, colons were escaped with a backslash but
 backslashes were not themselves escaped with a backslash, which lead to
-ambiguity: if the -x option took two arguments (as in
+ambiguity: '-x foo\:bar' (one argument with a backslashed colon) and
+'-x foo\\ bar' (two argumnets, and the first one ends in a backslash) would
+both set $opt_args[-x] to the same value.  This example assumes the -x
+option's spec declared two arguments, as in:
     _arguments : -x:foo:${action}:bar:$action
-), it would be impossible to tell from $opt_args whether the command-line
-was '-x foo\:bar' or '-x foo\\ bar'.
+
+For the more common case of non-repeatable options that take a single
+argument, completion functions now have to unescape not only colons but
+also backslashes when obtaining the option's argument from $opt_args.
 
 Incompatibilities between 5.0.8 and 5.2
 ---------------------------------------


  reply	other threads:[~2016-09-08 11:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-04 18:26 Daniel Shahaf
2016-09-07  7:03 ` Bart Schaefer
2016-09-07 22:07   ` Daniel Shahaf
2016-09-08  0:13     ` Bart Schaefer
2016-09-08 11:01       ` Daniel Shahaf [this message]
2016-09-08 15:49         ` 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=20160908110115.GA1707@fujitsu.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-workers@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).