zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: oxiedi@yandex.ru
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH 2/2] _arguments: Add the -0 flag, which makes $opt_args be populated sanely.
Date: Tue, 28 Apr 2020 17:54:15 +0000	[thread overview]
Message-ID: <20200428175415.60ebae64@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <1314911588066668@iva8-5e86d95f65ab.qloud-c.yandex.net>

oxiedi@yandex.ru wrote on Tue, 28 Apr 2020 14:37 +0500:
> > With this, «local -a values=( ${(0)opt_args[--foo]} )» would get the
> > value or values of the --foo option, as typed on the command line.
> > Without this, the completion function would have to reverse the "escape
> > colons and backslashes and join with colons" operation, and I don't know
> > of an easy way to do that.  
> 
> I've used
> 
>     local -a values
>     IFS=: read -A values <<<$opt_args[--foo]
> 
> once. Does it have some drawbacks?

Good idea, thanks.

It would DTWT when there's a literal newline in ${opt_args[--foo]}.

Also, it requires an additional temporary variable before accessing
${opt_args[--foo]} whenever the value of --foo may contain colons, even
if the --foo option is not repeatable.

On the other hand, the NUL separators approach would DTWT when there is
a literal NUL in the arguments.  That could in theory happen when
completing the arguments to a builtin.  If someone runs into _that_,
they should implement and use dana's ${(s.:..\.)} [grep for «spsep»],
or invent another way for _arguments to communicate the values to its
caller.

Thanks again,

Daniel

      reply	other threads:[~2020-04-28 17:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27 19:30 [PATCH 1/2] internal: Add a second parameter to zlinklist2array(), analogously to hlinklist2array() Daniel Shahaf
2020-04-27 19:30 ` [PATCH 2/2] _arguments: Add the -0 flag, which makes $opt_args be populated sanely Daniel Shahaf
2020-04-27 20:06   ` dana
2020-04-28  9:37   ` oxiedi
2020-04-28 17:54     ` Daniel Shahaf [this message]

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=20200428175415.60ebae64@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=oxiedi@yandex.ru \
    --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).