Commit f0d5c597 by Adam Stankiewicz

fix: Ensure cleaned directory did not exist

parent 0d7a0515
...@@ -107,6 +107,8 @@ done ...@@ -107,6 +107,8 @@ done
[ -n "$VERSION_NAME" ] || VERSION_NAME="${DEFINITION##*/}" [ -n "$VERSION_NAME" ] || VERSION_NAME="${DEFINITION##*/}"
PREFIX="${RBENV_ROOT}/versions/${VERSION_NAME}" PREFIX="${RBENV_ROOT}/versions/${VERSION_NAME}"
[ -d "${PREFIX}" ] && PREFIX_EXISTS=1
# If the installation prefix exists, prompt for confirmation unless # If the installation prefix exists, prompt for confirmation unless
# the --force option was specified. # the --force option was specified.
if [ -z "$FORCE" ] && [ -d "${PREFIX}/bin" ]; then if [ -z "$FORCE" ] && [ -d "${PREFIX}/bin" ]; then
...@@ -137,7 +139,7 @@ for hook in "${before_hooks[@]}"; do eval "$hook"; done ...@@ -137,7 +139,7 @@ for hook in "${before_hooks[@]}"; do eval "$hook"; done
# Plan cleanup on unsuccessful installation. # Plan cleanup on unsuccessful installation.
cleanup() { cleanup() {
rm -rf "$PREFIX" [ -z "${PREFIX_EXISTS}" ] && rm -rf "$PREFIX"
} }
trap cleanup SIGINT trap cleanup SIGINT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment