The Wayback Machine - https://web.archive.org/web/20221220124215/https://github.com/github/hub/pull/2214
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass $EDITOR to the shell #2214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

bk2204
Copy link

@bk2204 bk2204 commented Aug 1, 2019

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-editor and 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.

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-editor
and 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.
@mislav
Copy link
Member

mislav commented Aug 19, 2019

Excellent explanation and work; thank you. Please give me some more time to review and test; I'm just back from vacation and catching up. 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 participants