diff --git a/bin/pyenv-sh-activate b/bin/pyenv-sh-activate index eaa6b75..8d98900 100755 --- a/bin/pyenv-sh-activate +++ b/bin/pyenv-sh-activate @@ -41,10 +41,14 @@ fi if [ "${#versions[@]}" -gt 1 ]; then echo "pyenv-virtualenv: cannot activate multiple versions at once: ${versions[@]}" 1>&2 + echo "false" exit 1 fi -pyenv-virtualenv-prefix "${versions}" 1>/dev/null +if ! pyenv-virtualenv-prefix "${versions}" 1>/dev/null; then + echo "false" + exit 1 +fi shell="$(basename "${PYENV_SHELL:-$SHELL}")" case "$shell" in diff --git a/test/activate.bats b/test/activate.bats index a6a65d0..44a8b15 100644 --- a/test/activate.bats +++ b/test/activate.bats @@ -137,13 +137,17 @@ EOS } @test "should fail if the version is not a virtualenv" { - stub pyenv-virtualenv-prefix "3.3.3 : false" + stub pyenv-virtualenv-prefix "3.3.3 : echo \"not a virtualenv\" 1>&2; false" run pyenv-sh-activate "3.3.3" unstub pyenv-virtualenv-prefix assert_failure + assert_output <