Should not persist PYENV_DEACTIVATE after failed attempt to deactivate and activate

This commit is contained in:
Yamashita Yuu
2014-07-05 06:53:46 +09:00
parent abfda4bac9
commit 0de2cdbbc3
2 changed files with 30 additions and 15 deletions

View File

@@ -81,11 +81,14 @@ function _pyenv_virtualenv_hook --on-event fish_prompt;
return 0 return 0
end end
if [ "\$PYENV_ACTIVATE" != (pyenv prefix) ] if [ "\$PYENV_ACTIVATE" != (pyenv prefix) ]
eval (pyenv sh-deactivate --no-error --verbose) if eval (pyenv sh-deactivate --no-error --verbose)
eval (pyenv sh-activate --no-error --verbose) eval (pyenv sh-activate --no-error --verbose); or set -e PYENV_DEACTIVATE
else
eval (pyenv sh-activate --no-error --verbose)
end
end end
else else
if [ "\$PYENV_DEACTIVATE" != (pyenv prefix) ] if [ -z "\$VIRTUAL_ENV" ]; and [ "\$PYENV_DEACTIVATE" != (pyenv prefix) ]
eval (pyenv sh-activate --no-error --verbose) eval (pyenv sh-activate --no-error --verbose)
end end
end end
@@ -112,11 +115,14 @@ if [[ "$shell" != "fish" ]]; then
return 0 return 0
fi fi
if [ "x\$PYENV_ACTIVATE" != "x\`pyenv prefix\`" ]; then if [ "x\$PYENV_ACTIVATE" != "x\`pyenv prefix\`" ]; then
pyenv deactivate --no-error --verbose if pyenv deactivate --no-error --verbose; then
pyenv activate --no-error --verbose pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE
else
pyenv activate --no-error --verbose
fi
fi fi
else else
if [ "x\$PYENV_DEACTIVATE" != "x\`pyenv prefix\`" ]; then if [ -z "\$VIRTUAL_ENV" ] && [ "x\$PYENV_DEACTIVATE" != "x\`pyenv prefix\`" ]; then
pyenv activate --no-error --verbose pyenv activate --no-error --verbose
fi fi
fi fi

View File

@@ -37,11 +37,14 @@ _pyenv_virtualenv_hook() {
return 0 return 0
fi fi
if [ "x\$PYENV_ACTIVATE" != "x\`pyenv prefix\`" ]; then if [ "x\$PYENV_ACTIVATE" != "x\`pyenv prefix\`" ]; then
pyenv deactivate --no-error --verbose if pyenv deactivate --no-error --verbose; then
pyenv activate --no-error --verbose pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE
else
pyenv activate --no-error --verbose
fi
fi fi
else else
if [ "x\$PYENV_DEACTIVATE" != "x\`pyenv prefix\`" ]; then if [ -z "\$VIRTUAL_ENV" ] && [ "x\$PYENV_DEACTIVATE" != "x\`pyenv prefix\`" ]; then
pyenv activate --no-error --verbose pyenv activate --no-error --verbose
fi fi
fi fi
@@ -64,11 +67,14 @@ function _pyenv_virtualenv_hook --on-event fish_prompt;
return 0 return 0
end end
if [ "\$PYENV_ACTIVATE" != (pyenv prefix) ] if [ "\$PYENV_ACTIVATE" != (pyenv prefix) ]
eval (pyenv sh-deactivate --no-error --verbose) if eval (pyenv sh-deactivate --no-error --verbose)
eval (pyenv sh-activate --no-error --verbose) eval (pyenv sh-activate --no-error --verbose); or set -e PYENV_DEACTIVATE
else
eval (pyenv sh-activate --no-error --verbose)
end
end end
else else
if [ "\$PYENV_DEACTIVATE" != (pyenv prefix) ] if [ -z "\$VIRTUAL_ENV" ]; and [ "\$PYENV_DEACTIVATE" != (pyenv prefix) ]
eval (pyenv sh-activate --no-error --verbose) eval (pyenv sh-activate --no-error --verbose)
end end
end end
@@ -88,11 +94,14 @@ _pyenv_virtualenv_hook() {
return 0 return 0
fi fi
if [ "x\$PYENV_ACTIVATE" != "x\`pyenv prefix\`" ]; then if [ "x\$PYENV_ACTIVATE" != "x\`pyenv prefix\`" ]; then
pyenv deactivate --no-error --verbose if pyenv deactivate --no-error --verbose; then
pyenv activate --no-error --verbose pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE
else
pyenv activate --no-error --verbose
fi
fi fi
else else
if [ "x\$PYENV_DEACTIVATE" != "x\`pyenv prefix\`" ]; then if [ -z "\$VIRTUAL_ENV" ] && [ "x\$PYENV_DEACTIVATE" != "x\`pyenv prefix\`" ]; then
pyenv activate --no-error --verbose pyenv activate --no-error --verbose
fi fi
fi fi