Unset shell version only if the deactivate has invoked

This commit is contained in:
Yamashita Yuu
2014-07-04 20:27:55 +09:00
parent c09a6d3d6c
commit 0b5e0cf592
2 changed files with 17 additions and 10 deletions

View File

@@ -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 <<EOS
if functions -q deactivate
setenv PYENV_DEACTIVATE "\$VIRTUAL_ENV";
deactivate;
end;
@@ -21,16 +35,9 @@ EOS
;;
* )
cat <<EOS
if declare -f deactivate 1>/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

View File

@@ -28,10 +28,10 @@ EOS
assert_success
assert_output <<EOS
if declare -f deactivate 1>/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 <<EOS
if functions -q deactivate
pyenv shell --unset;
setenv PYENV_DEACTIVATE "\$VIRTUAL_ENV";
deactivate;
end;
pyenv shell --unset;
EOS
}