diff --git a/libexec/pyenv-version b/libexec/pyenv-version index cec2c945..dd5fa29a 100755 --- a/libexec/pyenv-version +++ b/libexec/pyenv-version @@ -8,10 +8,13 @@ set -e [ -n "$PYENV_DEBUG" ] && set -x +exitcode=0 OLDIFS="$IFS" -IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name)) +IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name)) || exitcode=$? IFS="$OLDIFS" for PYENV_VERSION_NAME in "${PYENV_VERSION_NAMES[@]}"; do echo "$PYENV_VERSION_NAME (set by $(pyenv-version-origin))" done + +exit $exitcode diff --git a/test/version-name.bats b/test/version-name.bats index 2556e005..00e4771b 100644 --- a/test/version-name.bats +++ b/test/version-name.bats @@ -72,6 +72,19 @@ pyenv: version \`1.2' is not installed OUT } +pyenv-version-name-without-stderr() { + pyenv-version-name 2>/dev/null +} + +@test "one missing version (without stderr)" { + create_version "3.4.2" + PYENV_VERSION="1.2:3.4.2" run pyenv-version-name-without-stderr + assert_failure + assert_output < ".python-version" <<<"python-2.7.6" diff --git a/test/version.bats b/test/version.bats index 8d933d28..120ec51d 100644 --- a/test/version.bats +++ b/test/version.bats @@ -40,7 +40,7 @@ setup() { @test "set by PYENV_VERSION, one missing" { create_version "3.3.3" PYENV_VERSION=3.3.3:1.2 run pyenv-version - assert_success + assert_failure assert_output </dev/null +} + +@test "set by PYENV_VERSION, one missing (stderr filtered)" { + create_version "3.3.3" + PYENV_VERSION=3.4.2:3.3.3 run pyenv-version-without-stderr + assert_failure + assert_output <