Also handle non-absolute paths being used for $EDITOR
This commit is contained in:
@@ -226,7 +226,18 @@ def setup_environment(opts, args):
|
|||||||
if 'EDITOR' not in os.environ:
|
if 'EDITOR' not in os.environ:
|
||||||
shell_env = read_shell_environment(opts)
|
shell_env = read_shell_environment(opts)
|
||||||
if 'EDITOR' in shell_env:
|
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:
|
else:
|
||||||
os.environ['EDITOR'] = opts.editor
|
os.environ['EDITOR'] = opts.editor
|
||||||
if args.listen_on:
|
if args.listen_on:
|
||||||
|
|||||||
Reference in New Issue
Block a user