From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] edit-command-line breaks arguments with spaces
Date: Sat, 14 Oct 2017 01:52:04 +0000 [thread overview]
Message-ID: <1507945924.3744661.1138358040.4B6A109D@webmail.messagingengine.com> (raw)
In-Reply-To: <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;;
next prev parent reply other threads:[~2017-10-14 1:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-13 23:05 Marco Hinz
2017-10-14 0:07 ` Daniel Shahaf
2017-10-14 0:45 ` Marco Hinz
2017-10-14 0:55 ` Bart Schaefer
2017-10-14 1:52 ` Daniel Shahaf [this message]
2017-10-14 4:21 ` Phil Pennock
2017-10-14 13:57 ` Daniel Shahaf
2017-10-14 1:56 ` Daniel Shahaf
2017-10-14 18:40 ` Marco Hinz
2017-10-15 1:35 ` Bart Schaefer
2017-10-15 14:15 ` Marco Hinz
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=1507945924.3744661.1138358040.4B6A109D@webmail.messagingengine.com \
--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).