3 # Test if the named environment variable is set and not zero length
10 # Prints backtrace info
11 # filename:lineno:function
16 deep=$((${#BASH_SOURCE[@]} - 1))
18 while [ $level -le $deep ]; do
19 echo "${BASH_SOURCE[$deep]}:${BASH_LINENO[$deep-1]}:${FUNCNAME[$deep-1]}"
24 # Prints line number and "message" in error format
25 # err $LINENO "message"
29 xtrace=$(set +o | grep xtrace)
31 local msg="[ERROR] ${BASH_SOURCE[2]}:$1 $2"
33 if [[ -n ${LOGDIR} ]]; then
34 echo $msg >> "${LOGDIR}/error.log"
40 # Prints line number and "message" then exits
41 # die $LINENO "message"
46 if [ $exitcode == 0 ]; then
51 # Give buffers a second to flush
56 # Checks an environment variable is not set or has length 0 OR if the
57 # exit code is non-zero and prints "message" and exits
58 # NOTE: env-var is the variable name without a '$'
59 # die_if_not_set $LINENO env-var "message"
60 function die_if_not_set {
63 xtrace=$(set +o | grep xtrace)
67 if ! is_set $evar || [ $exitcode != 0 ]; then