mirror of
https://github.com/pyenv/pyenv.git
synced 2025-04-10 22:55:09 +00:00
Simplify version file read
Avoid a subshell and external `cut` invocation, as well as a throwaway intermediate array.
This commit is contained in:
parent
cec6d46792
commit
b39d4291be
1 changed files with 1 additions and 2 deletions
|
@ -8,8 +8,7 @@ VERSION_FILE="$1"
|
|||
if [ -s "$VERSION_FILE" ]; then
|
||||
# Read the first word from the specified version file. Avoid reading it whole.
|
||||
IFS="${IFS}"$'\r'
|
||||
words=( $(cut -b 1-1024 "$VERSION_FILE") )
|
||||
version="${words[0]}"
|
||||
read -n 1024 -d "" -r version _ <"$VERSION_FILE" || :
|
||||
|
||||
if [ "$version" = ".." ] || [[ $version == */* ]]; then
|
||||
echo "rbenv: invalid version in \`$VERSION_FILE'" >&2
|
||||
|
|
Loading…
Add table
Reference in a new issue