mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-02 16:41:16 -05:00
Merge pull request #1393 from scop/refactor/simplify-version-file-read
Simplify version file read
This commit is contained in:
commit
c6cc0a1959
1 changed files with 2 additions and 3 deletions
|
@ -5,11 +5,10 @@ set -e
|
||||||
|
|
||||||
VERSION_FILE="$1"
|
VERSION_FILE="$1"
|
||||||
|
|
||||||
if [ -e "$VERSION_FILE" ]; then
|
if [ -s "$VERSION_FILE" ]; then
|
||||||
# Read the first word from the specified version file. Avoid reading it whole.
|
# Read the first word from the specified version file. Avoid reading it whole.
|
||||||
IFS="${IFS}"$'\r'
|
IFS="${IFS}"$'\r'
|
||||||
words=( $(cut -b 1-1024 "$VERSION_FILE") )
|
read -n 1024 -d "" -r version _ <"$VERSION_FILE" || :
|
||||||
version="${words[0]}"
|
|
||||||
|
|
||||||
if [ "$version" = ".." ] || [[ $version == */* ]]; then
|
if [ "$version" = ".." ] || [[ $version == */* ]]; then
|
||||||
echo "rbenv: invalid version in \`$VERSION_FILE'" >&2
|
echo "rbenv: invalid version in \`$VERSION_FILE'" >&2
|
||||||
|
|
Loading…
Reference in a new issue