ruby-build/bin/rbenv-uninstall

55 lines
1 KiB
Text
Raw Permalink Normal View History

2012-08-08 05:36:09 +03:00
#!/usr/bin/env bash
set -e
# Provide rbenv completions
if [ "$1" = "--complete" ]; then
exec rbenv versions --bare
2012-08-08 05:36:09 +03:00
fi
if [ -z "$RBENV_ROOT" ]; then
RBENV_ROOT="${HOME}/.rbenv"
fi
2012-08-15 15:08:53 -05:00
unset FORCE
if [ "$1" = "-f" ]; then
2012-08-15 15:08:53 -05:00
FORCE=true
shift
fi
2012-08-08 05:36:09 +03:00
DEFINITION="$1"
case "$DEFINITION" in
"" | -* )
{ echo "usage: rbenv uninstall [-f] VERSION"
echo
echo " -f Attempt to remove the specified version without prompting"
echo " for confirmation. If the version does not exist, do not"
echo " display an error message."
echo
2012-08-15 15:08:53 -05:00
echo "Installed versions:"
rbenv versions --bare | sed 's/^/ /'
2012-08-08 05:36:09 +03:00
echo
} >&2
exit 1
;;
esac
VERSION_NAME="${DEFINITION##*/}"
PREFIX="${RBENV_ROOT}/versions/${VERSION_NAME}"
if [ -z "$FORCE" ]; then
if [ ! -d "$PREFIX" ]; then
echo "rbenv: version \`$VERSION_NAME' not installed" >&2
exit 1
fi
read -p "rbenv: remove $PREFIX? "
case "$REPLY" in
y* | Y* ) ;;
* ) exit 1 ;;
esac
fi
if [ -d "$PREFIX" ]; then
rm -rf "$PREFIX"
rbenv rehash
2012-08-08 05:36:09 +03:00
fi