Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] edit-command-line breaks arguments with spaces
- X-seq: zsh-workers 41885
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [PATCH] edit-command-line breaks arguments with spaces
- Date: Sat, 14 Oct 2017 01:52:04 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=cdPiNK 0Yj3eUEGzTIn2rxb4tm7ganhnzHO1CO70j4i4=; b=wg9nTJoIGDGYpqzhmUUoJc THs9gVel8azPexwmtufVGaErn73OpZMGL7vIkBTMpCiTfrI79wQX3EBlUtD5UhL4 l+xsDfEoZaLsKP1kJRUclhQcrmIDkv7PJkHbSx67T+nHM0WuJkllXBnTFShpszj+ iOKTvWOcaodLBLvfMYzq7JfU5FwEEQ5jjKZ0Wsc/qt0zdTiNUMbPi673n2KoeMDF SxzOq18D/jf6smn8mZ0VCmnrTr7BhLO6wQH7CuBEIbBlKv6QbFWiaIAcweUGvn7Z CqqsiYgnrHooe9/HWTHPNDezAquIlmOF2RUNcGgSOOoVyiVI78AtmC7dBHHremNw ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=cdPiNK 0Yj3eUEGzTIn2rxb4tm7ganhnzHO1CO70j4i4=; b=Gjz3UA1H74YiPu0WFtfRnv NtiZmt4AVS6aV46ifaw8yCEwbm8rddye5DInpve5XuDdM45IfLFMJtdZnoP0XgLs TqToxiACd0VEjvxKczGv9+i6tczbd2Jf3dMJegI4+ZccpHwabQuz7bFbZaJx9LqQ CG+k7mf1Cj50jxGhgo452fs0zHogWOonwXteRV9MGn0oOzqmxMd+05NrWWZoHTSs JfSbqpalaL0VKtftNos9WE3qsgeza2w+9PZG1YaIqCIES+VetCE/imW2cc5AgyZi 6t/9o+3iq2/cnKwToGaLBKfOoQLeovEgbF9tNIGuGNPaPxotvsk4upkbA0cFIXqg ==
- In-reply-to: <171013175555.ZM12982@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <4B40504C-14CC-4EE0-8A53-5CF67C67E37E@gmail.com> <1507939677.3717869.1138301848.03470D9F@webmail.messagingengine.com> <171013175555.ZM12982@torch.brasslantern.com>
Bart Schaefer wrote on Fri, 13 Oct 2017 17:55 -0700:
> On Oct 14, 12:07am, Daniel Shahaf wrote:
> } Subject: Re: [PATCH] edit-command-line breaks arguments with spaces
> }
> } Marco Hinz wrote on Sat, 14 Oct 2017 01:05 +0200:
> } > + eval "${editor[@]} +${#lines}:$((${#lines[-1]} + 1)) $1";;
> } > + (*) eval "${editor[@]} $1";;
> }
> } LGTM, except that $1 should be changed into ${(q)1} due to the eval.
>
> Wouldn't this work and be preferable to eval?
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
So this edge case seems to favour eval.
Come to think of it, using eval will make $EDITOR subject to alias expansions.
> diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line
> index 353f260..f77eb35 100644
> --- a/Functions/Zle/edit-command-line
> +++ b/Functions/Zle/edit-command-line
> @@ -15,15 +15,15 @@
> (( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[2]
>
> # Open the editor, placing the cursor at the right place if we know how.
> - local editor=${${VISUAL:-${EDITOR:-vi}}}
> + local editor=(${(Q)${(z)${VISUAL:-${EDITOR:-vi}}}})
> case $editor in
> (*vim*)
> integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 ))
> - ${=editor} -c "normal! ${byteoffset}go" -- $1;;
> + ${editor} -c "normal! ${byteoffset}go" -- $1;;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author