pyenv/libexec/rbenv-sh-shell

50 lines
1.1 KiB
Text
Raw Normal View History

#!/usr/bin/env bash
#
# Summary: Set or show the shell-specific Ruby version
#
# Usage: rbenv shell <version>
# rbenv shell --unset
#
# Sets a shell-specific Ruby version by setting the `RBENV_VERSION'
# environment variable in your shell. This version overrides both
# project-specific versions and the global version.
#
# <version> should be a string matching a Ruby version known to rbenv.
# The special version string `system' will use your default system Ruby.
# Run `rbenv versions' for a list of available Ruby versions.
set -e
[ -n "$RBENV_DEBUG" ] && set -x
2011-09-09 08:18:14 -04:00
# Provide rbenv completions
if [ "$1" = "--complete" ]; then
2011-09-13 14:12:04 -04:00
echo --unset
echo system
exec rbenv-versions --bare
fi
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"
exit
2011-09-09 08:18:14 -04:00
fi
# Make sure the specified version is installed.
if rbenv-prefix "$version" >/dev/null; then
echo "export RBENV_VERSION=\"${version}\""
else
echo "return 1"
exit 1
fi