Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH 2/2] _arguments: Add the -0 flag, which makes $opt_args be populated sanely.



On 27 Apr 2020, at 14:30, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> 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 think this is a problem in a few other parts of the completion system
(though i can't remember specifically where), and with anything that uses DSV,
like PATH-style variables. I always thought it'd be cool if (j) and (s)
supported optional (un)escaping, maybe something like this:

  % arr=( 'foo' 'bar:baz' 'qux\quux' )
  % print -r ${str::=${(j<:><\>)arr}}  # Join by :, use \ as escape character
  foo:bar\:baz:qux\\quux
  % print -rl ${(s<:><\>)str}  # Split by :, use \ as escape character
  foo
  bar:baz
  qux\quux

Then you wouldn't have to do weird find/replace stuff, and it wouldn't break
if you had like an escaped back-slash in front of your delimiter

In this case `_arguments -0` would be faster/simpler and require less
'user-land' boiler-plate though. Haven't looked closely at the patch, but i'd
use it

dana



Messages sorted by: Reverse Date, Date, Thread, Author