mirror of
https://gitlab.com/spaceti-app/integrations/common/server-sdk.git
synced 2026-07-12 12:50:50 +02:00
39 lines
763 B
Bash
Executable File
39 lines
763 B
Bash
Executable File
# @see https://intoli.com/blog/exit-on-errors-in-bash-scripts/
|
|
set -e
|
|
|
|
function exit_function() {
|
|
LASTRES=$?; LAST=$BASH_COMMAND; # save last command and status
|
|
if [[ "$LASTRES" -ne 0 ]]; then
|
|
fail "Command: \"$LAST\" exited with exit code: $LASTRES";
|
|
exit 1;
|
|
elif [ "$FAIL" == "true" ]; then
|
|
fail finished with error;
|
|
exit 1;
|
|
else
|
|
pass "finished";
|
|
fi
|
|
}
|
|
|
|
trap exit_function EXIT
|
|
|
|
# ################
|
|
# Output funcitons
|
|
# ################
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
function info () {
|
|
echo -e "[${BLUE} $@ ${NC}]"
|
|
}
|
|
|
|
function pass() {
|
|
echo -e "[${GREEN}PASS${NC}] $@"
|
|
}
|
|
|
|
function fail() {
|
|
FAIL="true"; echo -e "[${RED}FAIL${NC}] $@"
|
|
}
|
|
|