From be6701e7b632a3ece8495d3425c129c2c94d629f Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Sun, 19 Jul 2015 01:00:24 +0900 Subject: [PATCH] Fix `Error: too many arguments.` on deactivating anaconda env --- bin/pyenv-sh-activate | 2 +- bin/pyenv-sh-deactivate | 2 +- bin/pyenv-virtualenv-init | 10 +++++----- test/init.bats | 20 ++++++++++---------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bin/pyenv-sh-activate b/bin/pyenv-sh-activate index 3c416ba..ad1cba5 100755 --- a/bin/pyenv-sh-activate +++ b/bin/pyenv-sh-activate @@ -122,7 +122,7 @@ if [ -n "${conda_env}" ]; then cat </dev/null || true)" = "system" ]; then - pyenv deactivate --no-error --verbose + eval "\$(pyenv sh-deactivate --no-error --verbose)" unset PYENV_DEACTIVATE return 0 fi if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then - if pyenv deactivate --no-error --verbose; then + if eval "\$(pyenv sh-deactivate --no-error --verbose)"; then unset PYENV_DEACTIVATE - pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE + eval "\$(pyenv sh-activate --no-error --verbose)" || unset PYENV_DEACTIVATE else - pyenv activate --no-error --verbose + eval "\$(pyenv sh-activate --no-error --verbose)" fi fi else if [ -z "\$VIRTUAL_ENV" ] && [ "\$PYENV_DEACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then - pyenv activate --no-error --verbose || true + eval "\$(pyenv sh-activate --no-error --verbose)" || true fi fi }; diff --git a/test/init.bats b/test/init.bats index 6d36e2a..3f2ffa6 100644 --- a/test/init.bats +++ b/test/init.bats @@ -51,21 +51,21 @@ export PYENV_VIRTUALENV_INIT=1; _pyenv_virtualenv_hook() { if [ -n "\$PYENV_ACTIVATE" ]; then if [ "\$(pyenv version-name 2>/dev/null || true)" = "system" ]; then - pyenv deactivate --no-error --verbose + eval "\$(pyenv sh-deactivate --no-error --verbose)" unset PYENV_DEACTIVATE return 0 fi if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then - if pyenv deactivate --no-error --verbose; then + if eval "\$(pyenv sh-deactivate --no-error --verbose)"; then unset PYENV_DEACTIVATE - pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE + eval "\$(pyenv sh-activate --no-error --verbose)" || unset PYENV_DEACTIVATE else - pyenv activate --no-error --verbose + eval "\$(pyenv sh-activate --no-error --verbose)" fi fi else if [ -z "\$VIRTUAL_ENV" ] && [ "\$PYENV_DEACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then - pyenv activate --no-error --verbose || true + eval "\$(pyenv sh-activate --no-error --verbose)" || true fi fi }; @@ -113,21 +113,21 @@ export PYENV_VIRTUALENV_INIT=1; _pyenv_virtualenv_hook() { if [ -n "\$PYENV_ACTIVATE" ]; then if [ "\$(pyenv version-name 2>/dev/null || true)" = "system" ]; then - pyenv deactivate --no-error --verbose + eval "\$(pyenv sh-deactivate --no-error --verbose)" unset PYENV_DEACTIVATE return 0 fi if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then - if pyenv deactivate --no-error --verbose; then + if eval "\$(pyenv sh-deactivate --no-error --verbose)"; then unset PYENV_DEACTIVATE - pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE + eval "\$(pyenv sh-activate --no-error --verbose)" || unset PYENV_DEACTIVATE else - pyenv activate --no-error --verbose + eval "\$(pyenv sh-activate --no-error --verbose)" fi fi else if [ -z "\$VIRTUAL_ENV" ] && [ "\$PYENV_DEACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then - pyenv activate --no-error --verbose || true + eval "\$(pyenv sh-activate --no-error --verbose)" || true fi fi };