Improve error handling
This commit is contained in:
parent
111a5d8be3
commit
5a2e31e7f6
10
ghcup
10
ghcup
@ -130,24 +130,24 @@ FLAGS:
|
|||||||
## utilities ##
|
## utilities ##
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
(>&2 echo "$1")
|
(>&2 printf "\\033[0;31m%s\\033[0m\\n" "$1")
|
||||||
exit 2
|
exit 2
|
||||||
}
|
}
|
||||||
|
|
||||||
edo()
|
edo()
|
||||||
{
|
{
|
||||||
if ${VERBOSE} ; then
|
if ${VERBOSE} ; then
|
||||||
echo "$@" 1>&2
|
printf "\\033[0;34m%s\\033[0m\\n" "$*" 1>&2
|
||||||
fi
|
fi
|
||||||
"$@" || exit 2
|
"$@" || exit 2
|
||||||
}
|
}
|
||||||
|
|
||||||
echov() {
|
echov() {
|
||||||
if ${VERBOSE} ; then
|
if ${VERBOSE} ; then
|
||||||
echo "$1"
|
printf "\\033[0;34m%s\\033[0m\\n" "$1"
|
||||||
else
|
else
|
||||||
if [ -n "$2" ] ; then
|
if [ -n "$2" ] ; then
|
||||||
echov "$2"
|
printf "\\033[0;34m%s\\033[0m\\n" "$2"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -377,7 +377,7 @@ self_update() {
|
|||||||
edo ${downloader} ${downloader_opts} "${source_url}"
|
edo ${downloader} ${downloader_opts} "${source_url}"
|
||||||
edo mv ghcup "${target_location}"/ghcup
|
edo mv ghcup "${target_location}"/ghcup
|
||||||
edo chmod +x "${target_location}"/ghcup
|
edo chmod +x "${target_location}"/ghcup
|
||||||
)
|
) || die "failed to install"
|
||||||
|
|
||||||
printf_green "Done, make sure \"${target_location}\" is in your PATH!"
|
printf_green "Done, make sure \"${target_location}\" is in your PATH!"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user