Make uninstallation more robust

For an incomplete installation, we still want to remove
what is left over, so don't fail on non-existing symlinks
in $BIN_LOCATION.
This commit is contained in:
Julian Ospald 2018-10-27 14:45:14 +08:00
parent eb79e39074
commit 5bb5389192
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
1 changed files with 5 additions and 1 deletions

6
ghcup
View File

@ -872,9 +872,13 @@ rm_ghc() {
if ghc_already_installed "${myghcver}" ; then
for f in "${BIN_LOCATION}"/*-"${myghcver}" ; do
# https://tanguy.ortolo.eu/blog/article113/test-symlink
[ ! -e "${f}" ] && [ ! -h "${f}" ] && die "Something went wrong, ${f} does not exist!"
[ ! -e "${f}" ] && [ ! -h "${f}" ] && {
warning_message "No existing symlinks for ${myghcver} in ${BIN_LOCATION}, skipping"
break
}
edo rm "${f}"
done
[ -z "${inst_location}" ] && die "internal error: inst_location empty!"
edo rm -r "${inst_location}"