Also handle non-absolute paths being used for $EDITOR

This commit is contained in:
Kovid Goyal 2019-07-22 10:30:11 +05:30
parent 50e7351c73
commit 88f25ccc76
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -226,7 +226,18 @@ def setup_environment(opts, args):
if 'EDITOR' not in os.environ:
shell_env = read_shell_environment(opts)
if 'EDITOR' in shell_env:
os.environ['EDITOR'] = shell_env['EDITOR']
editor = shell_env['EDITOR']
if 'PATH' in shell_env:
import shlex
editor_cmd = shlex.split(editor)
if not os.path.isabs(editor_cmd[0]):
editor_cmd[0] = shutil.which(editor_cmd[0], path=shell_env['PATH'])
if editor_cmd[0]:
editor = ' '.join(map(shlex.quote, editor_cmd))
else:
editor = None
if editor:
os.environ['EDITOR'] = editor
else:
os.environ['EDITOR'] = opts.editor
if args.listen_on: