2011-09-10 20:45:22 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2011-09-12 11:11:59 -04:00
|
|
|
[ -n "$RBENV_DEBUG" ] && set -x
|
2011-09-09 08:18:14 -04:00
|
|
|
|
2011-09-13 13:38:34 -04:00
|
|
|
# Provide rbenv completions
|
|
|
|
if [ "$1" = "--complete" ]; then
|
2011-09-13 14:12:04 -04:00
|
|
|
echo --unset
|
|
|
|
echo system
|
2011-09-13 13:38:34 -04:00
|
|
|
exec rbenv-versions --bare
|
|
|
|
fi
|
|
|
|
|
2011-09-10 20:45:22 -04:00
|
|
|
version="$1"
|
|
|
|
|
|
|
|
if [ -z "$version" ]; then
|
|
|
|
if [ -z "$RBENV_VERSION" ]; then
|
|
|
|
echo "rbenv: no shell-specific version configured" >&2
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "echo \"\$RBENV_VERSION\""
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$version" = "--unset" ]; then
|
|
|
|
echo "unset RBENV_VERSION"
|
2012-12-12 20:58:41 -05:00
|
|
|
exit
|
2011-09-09 08:18:14 -04:00
|
|
|
fi
|
|
|
|
|
2011-09-10 20:45:22 -04:00
|
|
|
# Make sure the specified version is installed.
|
2012-12-12 20:58:41 -05:00
|
|
|
if rbenv-prefix "$version" >/dev/null; then
|
|
|
|
echo "export RBENV_VERSION=\"${version}\""
|
|
|
|
else
|
|
|
|
echo "return 1"
|
|
|
|
exit 1
|
|
|
|
fi
|