From 04ce86abe081246a27cd94d3e20db2a6d4000452 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 27 Sep 2017 10:25:11 -0400 Subject: [PATCH] fallback to PYENV_SHELL if it's available Signed-off-by: Kenneth Reitz --- pipenv/cli.py | 10 +++++----- pipenv/environments.py | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 3f133950..65ed9c56 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -49,7 +49,7 @@ from .environments import ( PYENV_ROOT, PYENV_INSTALLED, PIPENV_YES, PIPENV_DONT_LOAD_ENV, PIPENV_DEFAULT_PYTHON_VERSION, PIPENV_MAX_SUBPROCESS, PIPENV_DONT_USE_PYENV, SESSION_IS_INTERACTIVE, PIPENV_USE_SYSTEM, - PIPENV_DOTENV_LOCATION + PIPENV_DOTENV_LOCATION, PIPENV_SHELL ) # Backport required for earlier versions of Python. @@ -1125,11 +1125,11 @@ def activate_virtualenv(source=True): suffix = '' # Support for fish shell. - if 'fish' in os.environ['SHELL']: + if 'fish' in PIPENV_SHELL: suffix = '.fish' # Support for csh shell. - if 'csh' in os.environ['SHELL']: + if 'csh' in PIPENV_SHELL: suffix = '.csh' # Escape any spaces located within the virtualenv path to allow @@ -1545,7 +1545,7 @@ def cli( if completion: try: - os.environ['_PIPENV_COMPLETE'] = 'source-{0}'.format(os.environ['SHELL'].split(os.sep)[-1]) + os.environ['_PIPENV_COMPLETE'] = 'source-{0}'.format(PIPENV_SHELL.split(os.sep)[-1]) except KeyError: click.echo( 'Please ensure that the {0} environment variable ' @@ -1937,7 +1937,7 @@ def do_shell(three=None, python=False, fancy=False, shell_args=None): # Compatibility mode: if compat: try: - shell = os.environ['SHELL'] + shell = PIPENV_SHELL except KeyError: click.echo( crayons.red( diff --git a/pipenv/environments.py b/pipenv/environments.py index dfb7fcdd..537dd26e 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -83,3 +83,5 @@ PYENV_ROOT = os.environ.get('PYENV_ROOT') PYENV_INSTALLED = (bool(os.environ.get('PYENV_SHELL')) or bool(PYENV_ROOT)) SESSION_IS_INTERACTIVE = bool(os.isatty(sys.stdout.fileno())) + +PIPENV_SHELL = os.environ.get('SHELL') or os.environ.get('PYENV_SHELL')