From f657fad92635497a9045577cb7ca5b451b1e68ba Mon Sep 17 00:00:00 2001 From: Bartosz Janda Date: Wed, 14 Oct 2015 21:18:09 +0200 Subject: [PATCH] Passing return value from executed command. --- bin/pyenv-virtualenv-init | 8 ++++++-- test/init.bats | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index 2cb639c..f521808 100755 --- a/bin/pyenv-virtualenv-init +++ b/bin/pyenv-virtualenv-init @@ -77,11 +77,12 @@ fish ) cat </dev/null; or true) + set -l ret \$status if [ -n "\$PYENV_ACTIVATE" ] if [ (pyenv version-name 2>/dev/null; or true) = "system" ] pyenv deactivate --no-error --verbose set -e PYENV_DEACTIVATE - return 0 + return \$ret end if [ "\$PYENV_ACTIVATE" != "\$PYENV_PREFIX" ] if pyenv deactivate --no-error --verbose @@ -96,6 +97,7 @@ function _pyenv_virtualenv_hook --on-event fish_prompt; pyenv activate --no-error --verbose; or true end end + return \$ret end EOS ;; @@ -113,11 +115,12 @@ esac if [[ "$shell" != "fish" ]]; then cat </dev/null || true)" = "system" ]; then eval "\$(pyenv sh-deactivate --no-error --verbose)" unset PYENV_DEACTIVATE - return 0 + return \$ret fi if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then if eval "\$(pyenv sh-deactivate --no-error --verbose)"; then @@ -132,6 +135,7 @@ if [[ "$shell" != "fish" ]]; then eval "\$(pyenv sh-activate --no-error --verbose)" || true fi fi + return \$ret }; EOS diff --git a/test/init.bats b/test/init.bats index 7e7107f..ba6a30f 100644 --- a/test/init.bats +++ b/test/init.bats @@ -51,11 +51,12 @@ load test_helper assert_output </dev/null || true)" = "system" ]; then eval "\$(pyenv sh-deactivate --no-error --verbose)" unset PYENV_DEACTIVATE - return 0 + return \$ret fi if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then if eval "\$(pyenv sh-deactivate --no-error --verbose)"; then @@ -70,6 +71,7 @@ _pyenv_virtualenv_hook() { eval "\$(pyenv sh-activate --no-error --verbose)" || true fi fi + return \$ret }; if ! [[ "\$PROMPT_COMMAND" =~ _pyenv_virtualenv_hook ]]; then PROMPT_COMMAND="_pyenv_virtualenv_hook;\$PROMPT_COMMAND"; @@ -84,11 +86,12 @@ EOS setenv PYENV_VIRTUALENV_INIT 1; function _pyenv_virtualenv_hook --on-event fish_prompt; set -l PYENV_PREFIX (pyenv prefix 2>/dev/null; or true) + set -l ret \$status if [ -n "\$PYENV_ACTIVATE" ] if [ (pyenv version-name 2>/dev/null; or true) = "system" ] pyenv deactivate --no-error --verbose set -e PYENV_DEACTIVATE - return 0 + return \$ret end if [ "\$PYENV_ACTIVATE" != "\$PYENV_PREFIX" ] if pyenv deactivate --no-error --verbose @@ -103,6 +106,7 @@ function _pyenv_virtualenv_hook --on-event fish_prompt; pyenv activate --no-error --verbose; or true end end + return \$ret end EOS } @@ -113,11 +117,12 @@ EOS assert_output </dev/null || true)" = "system" ]; then eval "\$(pyenv sh-deactivate --no-error --verbose)" unset PYENV_DEACTIVATE - return 0 + return \$ret fi if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix 2>/dev/null || true)" ]; then if eval "\$(pyenv sh-deactivate --no-error --verbose)"; then @@ -132,6 +137,7 @@ _pyenv_virtualenv_hook() { eval "\$(pyenv sh-activate --no-error --verbose)" || true fi fi + return \$ret }; typeset -g -a precmd_functions if [[ -z \$precmd_functions[(r)_pyenv_virtualenv_hook] ]]; then