Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] edit-command-line breaks arguments with spaces
On 2017-10-14 at 01:52 +0000, Daniel Shahaf wrote:
> If $EDITOR is set to "vim -c ''", then:
>
> - current master passes «''» (two characters) for vim's argv[2]
>
> - using eval passes the empty string for vim's argv[2]
>
> - using ${(Q)} elides the "" entirely
No, the (Q) has nothing to do with it. The problem is that in zsh,
expanding an unquoted array variable omits empty elements.
So instead of «$editor» it needs to be «"${editor[@]}"» or
«"${(@)editor}"» to keep the empty elements present at _expansion_ time.
This is the same reason that even in zsh, in normal zsh mode of not
splitting on whitespace, when passing through remaining elements of argv
unmolested you still have to use «"$@"» instead of just «$@».
% FOO="vim -C ''"
% foo=("${(Q@)${(z)FOO}}")
% print $#foo
3
% print -l $foo
vim
-C
% print -l .$foo
.vim
.-C
.
% print -l "${(@)foo}"
vim
-C
%
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author