From 34065dddbb85bbbfddfc4adf4571e9ea6a4121c0 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Mon, 24 Mar 2014 19:23:36 +0900 Subject: [PATCH] reads only the first word from file --- libexec/pyenv-version-file-read | 6 ++---- test/version-file-read.bats | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) 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 <