mirror of
https://github.com/rbenv/ruby-build.git
synced 2025-12-07 19:11:24 +01:00
60 lines
1.2 KiB
Bash
Executable file
60 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# Summary: Uninstall a specific Ruby version
|
|
#
|
|
# Usage: rbenv uninstall [-f|--force] <version>
|
|
#
|
|
# -f Attempt to remove the specified version without prompting
|
|
# for confirmation. If the version does not exist, do not
|
|
# display an error message.
|
|
#
|
|
# See `rbenv versions` for a complete list of installed versions.
|
|
#
|
|
set -e
|
|
|
|
# Provide rbenv completions
|
|
if [ "$1" = "--complete" ]; then
|
|
exec rbenv versions --bare
|
|
fi
|
|
|
|
if [ -z "$RBENV_ROOT" ]; then
|
|
RBENV_ROOT="${HOME}/.rbenv"
|
|
fi
|
|
|
|
unset FORCE
|
|
if [ "$1" = "-f" ] || [ "$1" = "--force" ]; then
|
|
FORCE=true
|
|
shift
|
|
fi
|
|
|
|
DEFINITION="$1"
|
|
case "$DEFINITION" in
|
|
"" | -* )
|
|
# We can remove the sed fallback once rbenv 0.4.0 is widely available.
|
|
{ rbenv-help uninstall 2>/dev/null ||
|
|
sed -ne '/^#/!q;s/.\{1,2\}//;1,4d;p' < "$0"
|
|
} >&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
|
|
fi
|