Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.


Several attempts have been made to provide better handling of the EDITOR and VISUAL environment variables. However, because these commands can contain arbitrary shell code, it isn't possible to provide correct behavior without actually invoking the shell.
Create a new function that invokes the shell with the proper arguments. For all editor invocations, invoke the shell in the way that Git does, even though this is incompatible with the way that other software behaves. For example, Git allows the use of "$@" directly in the command, while most other programs, including Debian's
sensible-editorand Git LFS, require the user to wrap such commands in a shell function. It isn't possible to make it work in both cases, but we're trying to be like Git, so do what Git does.Rewrite the command line in verbose output so we don't show the user the doubled argument we need to pass for things to work correctly. Also, stop expanding environment variables in the editor code path, since the shell will do that for us.
I'm not 100% certain that this will catch all Windows Git installations; it's possible that there are other custom ones that won't install things the same way. However, since Git doesn't tell us what the path is for its
sh, we can't do anything but guess. This does work fine on macOS and Linux, and should be fine on all other Unix systems as well.Fixes #1482.