# ---------------------------------------------------------------------- # returncodes # ---------------------------------------------------------------------- typeset -i rc=0 # Fetch returncode of last executed command. # It summarizes all exitcodes into rc (= if any job failed it is <> 0) # It stores the last exitcode in myrc function fetchrc(){ myrc=$? echo rc=$myrc rc=$rc+$myrc } # ---------------------------------------------------------------------- # colors # ---------------------------------------------------------------------- # ------------------------------------------------------------ # color text # ------------------------------------------------------------ # set a terminal color by a keyword # param string keyword to set a color; one of reset | head|cmd|input | ok|warning|error function color(){ sColorcode="" case $1 in "reset") sColorcode="0" ;; "head") sColorcode="33" # yellow ;; "cmd") sColorcode="94" # light blue ;; "input") sColorcode="92" # green ;; "ok") sColorcode="92" # green ;; "warning") sColorcode="33" # yellow ;; "error") sColorcode="91" # red ;; esac if [ ! -z ${sColorcode} ]; then echo -ne "\e[${sColorcode}m" fi } function showPrompt(){ color input echo -n "$*" color reset } # ---------------------------------------------------------------------- # headlines # ---------------------------------------------------------------------- function h1(){ color head echo echo echo "########## $* ##########" echo color reset } function h2(){ color head echo echo "========== $* ==========" echo color reset } function h3(){ color head echo echo "---------- $*" color reset } # ----------------------------------------------------------------------