2011-08-18 21:11:40 +02:00
|
|
|
#!/usr/bin/env bash
|
2012-12-30 05:05:04 +01:00
|
|
|
# Usage: rbenv version-file-read <file>
|
2011-08-18 21:11:40 +02:00
|
|
|
set -e
|
2011-09-12 17:11:59 +02:00
|
|
|
[ -n "$RBENV_DEBUG" ] && set -x
|
2011-08-18 21:11:40 +02:00
|
|
|
|
|
|
|
VERSION_FILE="$1"
|
|
|
|
|
2022-03-08 19:56:22 +01:00
|
|
|
if [ -s "$VERSION_FILE" ]; then
|
2018-06-05 16:43:31 +02:00
|
|
|
# Read the first word from the specified version file. Avoid reading it whole.
|
2014-03-21 01:36:39 +01:00
|
|
|
IFS="${IFS}"$'\r'
|
2013-12-31 07:44:36 +01:00
|
|
|
words=( $(cut -b 1-1024 "$VERSION_FILE") )
|
2014-03-21 01:36:39 +01:00
|
|
|
version="${words[0]}"
|
2011-09-28 19:06:53 +02:00
|
|
|
|
2019-04-03 12:58:25 +02:00
|
|
|
if [ "$version" = ".." ] || [[ $version == */* ]]; then
|
|
|
|
echo "rbenv: invalid version in \`$VERSION_FILE'" >&2
|
|
|
|
elif [ -n "$version" ]; then
|
2011-09-28 19:06:53 +02:00
|
|
|
echo "$version"
|
|
|
|
exit
|
|
|
|
fi
|
2011-08-18 21:11:40 +02:00
|
|
|
fi
|
2011-09-09 22:52:31 +02:00
|
|
|
|
|
|
|
exit 1
|