mirror of
https://github.com/rbenv/ruby-build.git
synced 2026-01-02 04:51:37 +01:00
Autoclean on unsuccessful installation
This commit is contained in:
parent
a6395eb296
commit
0d7a05157e
1 changed files with 12 additions and 1 deletions
|
|
@ -135,6 +135,13 @@ fi
|
|||
# Execute `before_install` hooks.
|
||||
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
|
||||
# `rbenv rehash` after a successful installation.
|
||||
STATUS=0
|
||||
|
|
@ -144,6 +151,10 @@ ruby-build $KEEP $VERBOSE "$DEFINITION" "$PREFIX" || STATUS="$?"
|
|||
for hook in "${after_hooks[@]}"; do eval "$hook"; done
|
||||
|
||||
# Run `rbenv-rehash` after a successful installation.
|
||||
[ "$STATUS" != "0" ] || rbenv rehash
|
||||
if [ "$STATUS" == "0" ]; then
|
||||
rbenv rehash
|
||||
else
|
||||
cleanup
|
||||
fi
|
||||
|
||||
exit "$STATUS"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue