shell version set in activate should be unset in deactivate (#61)

This commit is contained in:
Yamashita Yuu
2014-12-23 11:21:52 +09:00
parent 4b198663c7
commit 191e806ba9
4 changed files with 46 additions and 19 deletions

View File

@@ -41,8 +41,9 @@ while [ $# -gt 0 ]; do
shift 1
done
no_shell=
versions=("$@")
if [ -z "$versions" ]; then
if [ -z "${versions}" ]; then
no_shell=1
OLDIFS="$IFS"
IFS=: versions=($(pyenv-version-name))
@@ -97,6 +98,16 @@ fi
if [ -z "$no_shell" ]; then
echo "pyenv shell \"${versions}\";"
# shell version set in pyenv-sh-activate should be unset
# https://github.com/yyuu/pyenv-virtualenv/issues/61
case "$shell" in
fish )
echo "setenv PYENV_ACTIVATE_SHELL 1;"
;;
* )
echo "export PYENV_ACTIVATE_SHELL=1;"
;;
esac
fi
prefix="$(pyenv-prefix "${versions}")"

View File

@@ -43,10 +43,18 @@ if [ -n "$VERBOSE" ]; then
echo " echo \"pyenv-virtualenv: deactivate ${prefix##*/}\" 1>&2;"
fi
if [ -z "${PYENV_VIRTUALENV_INIT}" ]; then
# Backward compatibility issue
# https://github.com/yyuu/pyenv-virtualenv/issues/26
if [ -n "${PYENV_ACTIVATE_SHELL}" ]; then
# shell version set in pyenv-sh-activate should be unset
# https://github.com/yyuu/pyenv-virtualenv/issues/61
echo " pyenv shell --unset;"
case "$shell" in
fish )
echo " set -e PYENV_ACTIVATE_SHELL;"
;;
* )
echo " unset PYENV_ACTIVATE_SHELL;"
;;
esac
fi
case "$shell" in