parent
d232aa4993
commit
34aa368e9b
@ -16,8 +16,8 @@ edo ./ghcup -v set 8.6.1
|
|||||||
edo ./ghcup -v set 8.4.3
|
edo ./ghcup -v set 8.4.3
|
||||||
|
|
||||||
# rm GHC
|
# rm GHC
|
||||||
edo ./ghcup -v rm 8.6.1
|
edo ./ghcup -v rm -f 8.6.1
|
||||||
edo ./ghcup -v rm 8.4.3
|
edo ./ghcup -v rm -f 8.4.3
|
||||||
|
|
||||||
# set GHC
|
# set GHC
|
||||||
edo ./ghcup -v set 8.2.2
|
edo ./ghcup -v set 8.2.2
|
||||||
|
37
ghcup
37
ghcup
@ -252,6 +252,7 @@ USAGE:
|
|||||||
|
|
||||||
FLAGS:
|
FLAGS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
|
-f, --force Don't prompt user
|
||||||
|
|
||||||
ARGS:
|
ARGS:
|
||||||
<VERSION> E.g. \"8.4.3\" or \"8.6.1\"
|
<VERSION> E.g. \"8.4.3\" or \"8.6.1\"
|
||||||
@ -627,6 +628,30 @@ unpack() {
|
|||||||
unset filename file_ext
|
unset filename file_ext
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# @FUNCTION: ask_for_confirmation
|
||||||
|
# @USAGE: [confirmation-msg]
|
||||||
|
# @DESCRIPTION:
|
||||||
|
# Asks the user for confirmation and returns 0 for yes, 1 for no.
|
||||||
|
# @RETURN: 0 if user confirmed, 1 otherwise
|
||||||
|
ask_for_confirmation() {
|
||||||
|
confirmation_msg=$1
|
||||||
|
|
||||||
|
if [ -n "${confirmation_msg}" ] ; then
|
||||||
|
printf "%s\\n(y/n and press Enter)\\n" "${confirmation_msg}"
|
||||||
|
else
|
||||||
|
printf "Confirm action: (y/n and press Enter)\\n"
|
||||||
|
fi
|
||||||
|
read -r answer
|
||||||
|
|
||||||
|
if [ "${answer}" != "${answer#[Yy]}" ] ;then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset confirmation_msg answer
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -870,6 +895,15 @@ rm_ghc() {
|
|||||||
[ -z "${myghcver}" ] && die "We are paranoid, ghcver not set"
|
[ -z "${myghcver}" ] && die "We are paranoid, ghcver not set"
|
||||||
|
|
||||||
if ghc_already_installed "${myghcver}" ; then
|
if ghc_already_installed "${myghcver}" ; then
|
||||||
|
[ -z "${inst_location}" ] && die "internal error: inst_location empty!"
|
||||||
|
|
||||||
|
if ! ${FORCE} ; then
|
||||||
|
if ! ask_for_confirmation "Really removing ${myghcver}? This will also recursively remove the following directory (please double-check): \"${inst_location}\"" ; then
|
||||||
|
warning_message "Not removing GHC..."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
for f in "${BIN_LOCATION}"/*-"${myghcver}" ; do
|
for f in "${BIN_LOCATION}"/*-"${myghcver}" ; do
|
||||||
# https://tanguy.ortolo.eu/blog/article113/test-symlink
|
# https://tanguy.ortolo.eu/blog/article113/test-symlink
|
||||||
[ ! -e "${f}" ] && [ ! -h "${f}" ] && {
|
[ ! -e "${f}" ] && [ ! -h "${f}" ] && {
|
||||||
@ -879,7 +913,6 @@ rm_ghc() {
|
|||||||
edo rm "${f}"
|
edo rm "${f}"
|
||||||
done
|
done
|
||||||
|
|
||||||
[ -z "${inst_location}" ] && die "internal error: inst_location empty!"
|
|
||||||
edo rm -r "${inst_location}"
|
edo rm -r "${inst_location}"
|
||||||
|
|
||||||
status_message "Successfully removed GHC ${myghcver}."
|
status_message "Successfully removed GHC ${myghcver}."
|
||||||
@ -1165,6 +1198,8 @@ while [ $# -gt 0 ] ; do
|
|||||||
while [ $# -gt 0 ] ; do
|
while [ $# -gt 0 ] ; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-h|--help) rm_usage;;
|
-h|--help) rm_usage;;
|
||||||
|
-f|--force) FORCE=true
|
||||||
|
shift 1;;
|
||||||
*) GHC_VER=$1
|
*) GHC_VER=$1
|
||||||
break;;
|
break;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user