Re: [PATCH v3 2/2] git-jump: invoke emacs/emacsclient
- From
Jeff King <peff@peff.net>
- Date
- Nov 21, 2022, 18:50 UTC
- Message-ID
- <Y3vId3rOmmkJnkGj@coredump.intra.peff.net>
- In-Reply-To
- <b4ad4c083c96d20873a649aab5f39cd061bd662a.1669033620.git.gitgitgadget@gmail.com>
On Mon, Nov 21, 2022 at 12:27:00PM +0000, Yoichi Nakayama via GitGitGadget wrote:
> +open_emacs() {
> + editor=`git var GIT_EDITOR`
> + eval "$editor --eval \"(prog1 (switch-to-buffer-other-frame (compilation-start \\\"git jump --stdout $@\\\" 'grep-mode)) (delete-other-windows) (select-frame-set-input-focus (selected-frame)))\""
> +}I think this subjects the user's arguments to an extra round of whitespace splitting. E.g., if I do:
git jump grep 'foo bar'
then the emacs command will see two arguments. The first is "--eval", and the second is the whole string:
prog1 (switch-to-buffer-other-frame (compilation-start "git jump --stdout grep foo bar" 'grep-mode)) (delete-other-windows) (select-frame-set-input-focus (selected-frame)))
But now we've lost fact that "foo bar" was a single string, and git-grep will complain (because it treats "bar" as a file to look in, which does not exist).
You'll have to either shell-quote the contents, or stuff it in a tempfile and read it with something like "cat /path/to/tempfile" in the emacs command (though I'm not sure if that would be racy when you're using something like emacsclient which may exit before the main emacs process runs the command).
-Peff