Commit 0d7a0515 by Adam Stankiewicz

Autoclean on unsuccessful installation

parent a6395eb2
...@@ -135,6 +135,13 @@ fi ...@@ -135,6 +135,13 @@ fi
# Execute `before_install` hooks. # Execute `before_install` hooks.
for hook in "${before_hooks[@]}"; do eval "$hook"; done for hook in "${before_hooks[@]}"; do eval "$hook"; done
# Plan cleanup on unsuccessful installation.
cleanup() {
rm -rf "$PREFIX"
}
trap cleanup SIGINT
# Invoke `ruby-build` and record the exit status in $STATUS. Run # Invoke `ruby-build` and record the exit status in $STATUS. Run
# `rbenv rehash` after a successful installation. # `rbenv rehash` after a successful installation.
STATUS=0 STATUS=0
...@@ -144,6 +151,10 @@ ruby-build $KEEP $VERBOSE "$DEFINITION" "$PREFIX" || STATUS="$?" ...@@ -144,6 +151,10 @@ ruby-build $KEEP $VERBOSE "$DEFINITION" "$PREFIX" || STATUS="$?"
for hook in "${after_hooks[@]}"; do eval "$hook"; done for hook in "${after_hooks[@]}"; do eval "$hook"; done
# Run `rbenv-rehash` after a successful installation. # Run `rbenv-rehash` after a successful installation.
[ "$STATUS" != "0" ] || rbenv rehash if [ "$STATUS" == "0" ]; then
rbenv rehash
else
cleanup
fi
exit "$STATUS" exit "$STATUS"
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