2011-08-18 15:11:40 -04:00
|
|
|
#!/usr/bin/env bash
|
2012-12-29 23:05:04 -05:00
|
|
|
# Usage: rbenv version-file-read <file>
|
2011-08-18 15:11:40 -04:00
|
|
|
set -e
|
2011-09-12 11:11:59 -04:00
|
|
|
[ -n "$RBENV_DEBUG" ] && set -x
|
2011-08-18 15:11:40 -04:00
|
|
|
|
|
|
|
VERSION_FILE="$1"
|
|
|
|
|
2022-03-08 13:56:22 -05:00
|
|
|
if [ -s "$VERSION_FILE" ]; then
|
2018-06-05 10:43:31 -04:00
|
|
|
# Read the first word from the specified version file. Avoid reading it whole.
|
2014-03-20 20:36:39 -04:00
|
|
|
IFS="${IFS}"$'\r'
|
2022-03-08 13:58:58 -05:00
|
|
|
read -n 1024 -d "" -r version _ <"$VERSION_FILE" || :
|
2011-09-28 13:06:53 -04:00
|
|
|
|
2019-04-03 06:58:25 -04:00
|
|
|
if [ "$version" = ".." ] || [[ $version == */* ]]; then
|
|
|
|
echo "rbenv: invalid version in \`$VERSION_FILE'" >&2
|
|
|
|
elif [ -n "$version" ]; then
|
2011-09-28 13:06:53 -04:00
|
|
|
echo "$version"
|
|
|
|
exit
|
|
|
|
fi
|
2011-08-18 15:11:40 -04:00
|
|
|
fi
|
2011-09-09 16:52:31 -04:00
|
|
|
|
|
|
|
exit 1
|