Kaynağa Gözat

reads only the first word from file

pull/150/merge
Yamashita Yuu 10 yıl önce
ebeveyn
işleme
34065dddbb
2 değiştirilmiş dosya ile 5 ekleme ve 7 silme
  1. +2
    -4
      libexec/pyenv-version-file-read
  2. +3
    -3
      test/version-file-read.bats

+ 2
- 4
libexec/pyenv-version-file-read Dosyayı Görüntüle

@ -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

+ 3
- 3
test/version-file-read.bats Dosyayı Görüntüle

@ -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 <<IN
2.7.6 one
3.3.5 two
IN
run pyenv-version-file-read my-version
assert_success "2.7.6:one:3.3.5:two"
assert_success "2.7.6:3.3.5"
}
@test "ignores leading blank lines" {

Yükleniyor…
İptal
Kaydet