diff --git a/libexec/pyenv-version-file-read b/libexec/pyenv-version-file-read index b5ec2c81..64d7f76e 100755 --- a/libexec/pyenv-version-file-read +++ b/libexec/pyenv-version-file-read @@ -9,14 +9,12 @@ if [ -e "$VERSION_FILE" ]; then # Read the first non-whitespace word from the specified version file. # Be careful not to load it whole in case there's something crazy in it. IFS="${IFS}"$'\r' - words=( $(cut -b 1-1024 "$VERSION_FILE") ) + words=( $(cut -b 1-1024 "$VERSION_FILE" | awk '{ print($1) }') ) versions=("${words[@]}") if [ -n "$versions" ]; then - OLDIFS="$IFS" - IFS=: + IFS=":" echo "${versions[*]}" - IFS="$OLDIFS" exit fi fi diff --git a/test/version-file-read.bats b/test/version-file-read.bats index 7b08ece3..d31037c2 100644 --- a/test/version-file-read.bats +++ b/test/version-file-read.bats @@ -38,16 +38,16 @@ setup() { @test "reads only the first word from file" { cat > my-version <<<"3.3.5 2.7.6 hi" run pyenv-version-file-read my-version - assert_success "3.3.5:2.7.6:hi" + assert_success "3.3.5" } -@test "loads only the first line in file" { +@test "loads *not* only the first line in file" { cat > my-version <