bugfix: support EDITOR values with spaces (#4523)

- previous code called `which` on $EDITOR, but that doesn't work for
  EDITORs like `emacs -nw` or `emacsclient -t -nw`.

- This patch just trusts EDITOR if it is set (same as previous
  behavior), and only uses the defaults if it's not.
This commit is contained in:
Todd Gamblin 2017-06-16 14:03:21 +02:00 committed by GitHub
parent 8b5e94976d
commit 790b06e0c3

View File

@ -212,16 +212,16 @@
from spack.util.executable import *
__all__ += spack.util.executable.__all__
# User's editor from the environment
# Default editors to use:
_default_editors = ['vim', 'vi', 'emacs', 'nano']
# Set up the user's editor
# $EDITOR environment variable has the highest precedence
editor = os.environ.get('EDITOR')
# The EDITOR environment variable has the highest precedence
if os.environ.get('EDITOR'):
_default_editors.insert(0, os.environ.get('EDITOR'))
editor = which(*_default_editors)
# if editor is not set, use some sensible defaults
if editor is not None:
editor = Executable(editor)
else:
editor = which('vim', 'vi', 'emacs', 'nano')
if not editor:
default = default_editors[0]