From bdd52a79cd6a61c55376fd76e5dbe49c4926cf81 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Sun, 8 Nov 2015 08:24:07 +0000 Subject: [PATCH] Revert `PYENV_DEACTIVATE` for backward compatibility --- bin/pyenv-sh-activate | 24 ++++++++++++++++++++++-- bin/pyenv-sh-deactivate | 14 ++++++++++++-- test/activate.bats | 10 ++++++++++ test/conda-activate.bats | 5 +++++ test/conda-deactivate.bats | 3 +++ test/deactivate.bats | 11 +++++++++++ 6 files changed, 63 insertions(+), 4 deletions(-) diff --git a/bin/pyenv-sh-activate b/bin/pyenv-sh-activate index 5917e17..75fc1c6 100755 --- a/bin/pyenv-sh-activate +++ b/bin/pyenv-sh-activate @@ -15,6 +15,7 @@ set -e [ -n "$PYENV_DEBUG" ] && set -x unset DEACTIVATE +unset FORCE unset QUIET unset VERBOSE @@ -28,6 +29,9 @@ while [ $# -gt 0 ]; do "--deactivate" ) DEACTIVATE=1 ;; + "--force" ) + FORCE=1 + ;; "--no-error" | "--quiet" ) QUIET=1 ;; @@ -95,6 +99,16 @@ if [[ "${VIRTUAL_ENV}" == "${prefix}" ]]; then exit 0 fi +if [[ "${PYENV_DEACTIVATE}" == "${prefix}" ]]; then + if [ -z "${FORCE}" ]; then + if [ -z "${QUIET}" ]; then + echo "pyenv-virtualenv: \`${venv}' is marked deactivated. use \`pyenv activate --force ${venv}' to activate forcibly." 1>&2 + fi + echo "false" + exit 1 + fi +fi + # Display setup instruction, if pyenv-virtualenv has not been initialized. # if 'pyenv virtualenv-init -' is not found in "$profile" if [ -z "$PYENV_VIRTUALENV_INIT" ]; then @@ -132,10 +146,16 @@ fi # virtualenv/pyvenv case "${shell}" in fish ) - echo "setenv VIRTUAL_ENV \"${prefix}\";" + cat <