2011-08-18 19:11:40 +00:00
|
|
|
#!/usr/bin/env bash
|
2012-12-30 04:05:04 +00:00
|
|
|
# Usage: rbenv version-file-read <file>
|
2011-08-18 19:11:40 +00:00
|
|
|
set -e
|
2011-09-12 15:11:59 +00:00
|
|
|
[ -n "$RBENV_DEBUG" ] && set -x
|
2011-08-18 19:11:40 +00:00
|
|
|
|
|
|
|
VERSION_FILE="$1"
|
|
|
|
|
|
|
|
if [ -e "$VERSION_FILE" ]; then
|
2012-12-13 00:45:06 +00:00
|
|
|
# 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.
|
2013-12-31 06:44:36 +00:00
|
|
|
words=( $(cut -b 1-1024 "$VERSION_FILE") )
|
2013-10-30 01:33:49 +00:00
|
|
|
version="${words[0]}"
|
2011-09-28 17:06:53 +00:00
|
|
|
|
|
|
|
if [ -n "$version" ]; then
|
|
|
|
echo "$version"
|
|
|
|
exit
|
|
|
|
fi
|
2011-08-18 19:11:40 +00:00
|
|
|
fi
|
2011-09-09 20:52:31 +00:00
|
|
|
|
|
|
|
exit 1
|