diff --git a/bin/pyenv-sh-deactivate b/bin/pyenv-sh-deactivate index 85e2803..a2a1d1f 100755 --- a/bin/pyenv-sh-deactivate +++ b/bin/pyenv-sh-deactivate @@ -10,10 +10,24 @@ set -e [ -n "$PYENV_DEBUG" ] && set -x shell="$(basename "${PYENV_SHELL:-$SHELL}")" +case "$shell" in +fish ) + echo "if functions -q deactivate" + ;; +* ) + echo "if declare -f deactivate 1>/dev/null 2>&1; then" + ;; +esac + +if [ -z "${PYENV_VIRTUALENV_INIT}" ]; then + # Backward compatibility issue + # https://github.com/yyuu/pyenv-virtualenv/issues/26 + echo " pyenv shell --unset;" +fi + case "$shell" in fish ) cat </dev/null 2>&1; then export PYENV_DEACTIVATE="\$VIRTUAL_ENV"; deactivate; fi; EOS ;; esac - -if [ -z "${PYENV_VIRTUALENV_INIT}" ]; then - # Backward compatibility issue - # https://github.com/yyuu/pyenv-virtualenv/issues/26 - echo "pyenv shell --unset;" -fi diff --git a/test/deactivate.bats b/test/deactivate.bats index 1f8331a..67faa2f 100644 --- a/test/deactivate.bats +++ b/test/deactivate.bats @@ -28,10 +28,10 @@ EOS assert_success assert_output </dev/null 2>&1; then + pyenv shell --unset; export PYENV_DEACTIVATE="\$VIRTUAL_ENV"; deactivate; fi; -pyenv shell --unset; EOS } @@ -57,10 +57,10 @@ EOS assert_success assert_output <