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"
|
|
|
|
|
|
|
|
if [ -e "$VERSION_FILE" ]; then
|
2012-12-12 19:45:06 -05: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 01:44:36 -05:00
|
|
|
words=( $(cut -b 1-1024 "$VERSION_FILE") )
|
2014-03-20 06:30:27 -04:00
|
|
|
version="${words[0]//[$'\r']}"
|
2011-09-28 13:06:53 -04:00
|
|
|
|
|
|
|
if [ -n "$version" ]; then
|
|
|
|
echo "$version"
|
|
|
|
exit
|
|
|
|
fi
|
2011-08-18 15:11:40 -04:00
|
|
|
fi
|
2011-09-09 16:52:31 -04:00
|
|
|
|
|
|
|
exit 1
|