|
|
|
@ -8,6 +8,10 @@ readonly MIAOU_BASH_ERROR MIAOU_BASH_DEBUG |
|
|
|
|
|
|
|
# FUNCTIONS |
|
|
|
|
|
|
|
function is_true { |
|
|
|
[[ "${1,,}" =~ ^(true|yes|1)$ ]] |
|
|
|
} |
|
|
|
|
|
|
|
# overridden function which permits backtracing of original `return` statement |
|
|
|
function false { |
|
|
|
>&2 echo "${BASH_SOURCE[1]}:${BASH_LINENO[0]} false" |
|
|
|
@ -178,8 +182,7 @@ function on_exit { |
|
|
|
} |
|
|
|
|
|
|
|
function debug { |
|
|
|
[[ "${MIAOU_BASH_DEBUG}" == true ]] && >/dev/tty echo "*********** DEBUG: $*" || |
|
|
|
true |
|
|
|
is_true "${MIAOU_BASH_DEBUG}" && >/dev/tty echo "*********** DEBUG: $*" || true |
|
|
|
} |
|
|
|
|
|
|
|
function dump_failure { |
|
|
|
@ -206,9 +209,9 @@ function dump_failure { |
|
|
|
function dump_stderr { |
|
|
|
last_trim=${1:-false} |
|
|
|
mapfile -t tmp_error <"$MIAOU_BASH_ERROR" |
|
|
|
$last_trim && unset 'tmp_error[-1]' && tmp_error=("${tmp_error[@]}") |
|
|
|
is_true "$last_trim" && unset 'tmp_error[-1]' && tmp_error=("${tmp_error[@]}") |
|
|
|
if [[ "${#tmp_error[@]}" -gt 0 ]]; then |
|
|
|
$MIAOU_BASH_DEBUG && >/dev/tty echo '---stderr---' |
|
|
|
debug '---stderr---' |
|
|
|
for i in "${tmp_error[@]}"; do |
|
|
|
>&4 echo -e "$i" |
|
|
|
done |
|
|
|
|