From 38d6c54c690df6d2589a7994dabe29ed3c541ec1 Mon Sep 17 00:00:00 2001 From: koksnuss Date: Sun, 23 Sep 2018 15:09:50 +0200 Subject: [PATCH] add ok function to exit with a generic error message after a previous call went wring --- bsf.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bsf.sh b/bsf.sh index d660ab2..13ac63b 100644 --- a/bsf.sh +++ b/bsf.sh @@ -12,6 +12,10 @@ sayn () { printf %s "$*" ; } ## check if user is root root () { [[ "$EUID" -eq 0 ]] ; } +## check if last call had errors +## if yes print generic error message and exit +ok() { [[ "$?" -ne 0 ]] && echo "ERROR, aborting." && exit 1; } + ## colors # use ANSI escape codes normal () { printf '\033[0m' ; }