Improve error/status messages
This commit is contained in:
parent
605b7420ce
commit
ee1d4e6aac
21
ghcup
21
ghcup
@ -164,7 +164,7 @@ ARGS:
|
||||
## utilities ##
|
||||
|
||||
die() {
|
||||
(>&2 printf "\\033[0;31m%s\\033[0m\\n" "$1")
|
||||
(>&2 red_message "$1")
|
||||
exit 2
|
||||
}
|
||||
|
||||
@ -204,6 +204,10 @@ warning_message() {
|
||||
printf "\\033[1;33m%s\\033[0m\\n" "$1"
|
||||
}
|
||||
|
||||
red_message() {
|
||||
printf "\\033[0;31m%s\\033[0m\\n" "$1"
|
||||
}
|
||||
|
||||
get_distro_name() {
|
||||
if [ -f /etc/os-release ]; then
|
||||
# freedesktop.org and systemd
|
||||
@ -481,14 +485,19 @@ show_ghc() {
|
||||
}
|
||||
|
||||
show_ghc_installed() {
|
||||
real_ghc=$(realpath "${BIN_LOCATION}/ghc")
|
||||
current_ghc="${BIN_LOCATION}/ghc"
|
||||
real_ghc=$(realpath "${current_ghc}" 2>/dev/null)
|
||||
|
||||
if [ -e "${real_ghc}" ] ; then
|
||||
if [ -L "${current_ghc}" ] ; then # is symlink
|
||||
if [ -e "${real_ghc}" ] ; then # exists (realpath was called)
|
||||
real_ghc="$(basename "${real_ghc}" | sed 's#ghc-##')"
|
||||
printf "%s" "${real_ghc}"
|
||||
else # is a broken symlink
|
||||
red_message "broken symlink"
|
||||
fi
|
||||
fi
|
||||
|
||||
unset real_ghc
|
||||
unset real_ghc current_ghc
|
||||
}
|
||||
|
||||
## rm subcommand ##
|
||||
@ -510,6 +519,10 @@ rm_ghc() {
|
||||
warning_message "${myghcver} doesn't appear to be installed, skipping"
|
||||
fi
|
||||
|
||||
status_message "Successfully removed GHC ${myghcver}, you might have to"
|
||||
status_message "set the currently active GHC now to fix dangling symlinks:"
|
||||
status_message " ghcup set <ghcver>"
|
||||
|
||||
unset myghcver inst_location f
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user