From 16e69e657157f555643bc656f958adb5950ee9dc Mon Sep 17 00:00:00 2001 From: Greg Werbin Date: Sun, 17 Apr 2016 19:10:24 -0400 Subject: [PATCH] Split the value of &shell option Before, the value of `&shell` was being passed verbatim to `jobstart` because no word splitting is done when the argument to `jobstart` is a list. This would cause errors if the user's `&shell` were set to something like `'/usr/local/bin/zsh -l'`. This does not, however, fix another potential edge case, when the shell command itself requires quoting (as per the example in the Neovim docs, option E91). After doing some testing, it appears that `jobstart()` cannot handle a quoted command, despite the recommendation in the manual (and despite the fact that commands like `:terminal` work just fine with double-quoted values for `&shell`). Whether this inconsistency is due to a bug or something else, additional defensive action is probably needed. For demonstration, try symlinking `/bin/bash` to `"./bad shell"`, and inside Neovim setting `let &shell='"./bad shell"'. Everything works fine, except `:call jobstart([&shell])` fails. Try various combinations of quoting and calls to `jobstart()`, `split()`, and such: there seems to be no way to get `jobstart()` to handle the quotes and spaces properly without additional manipulation up-front. --- autoload/gitgutter/diff.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/gitgutter/diff.vim b/autoload/gitgutter/diff.vim index 95fcc5f..3d7b1a5 100644 --- a/autoload/gitgutter/diff.vim +++ b/autoload/gitgutter/diff.vim @@ -132,7 +132,7 @@ function! gitgutter#diff#run_diff(realtime, preserve_full_diff) " Note that when `cmd` doesn't produce any output, i.e. the diff is empty, " the `stdout` event is not fired on the job handler. Therefore we keep " track of the jobs ourselves so we can spot empty diffs. - let job_id = jobstart([&shell, '-c', cmd], { + let job_id = jobstart(split(&shell) + ['-c', cmd], { \ 'on_stdout': function('gitgutter#handle_diff_job'), \ 'on_stderr': function('gitgutter#handle_diff_job'), \ 'on_exit': function('gitgutter#handle_diff_job')