|
|
|
@ -290,7 +290,6 @@ function dump_failure { |
|
|
|
function save_err_trace_to_main { |
|
|
|
miaou_debug "<save_stacktrace_to_stderr count=${#error_source[@]} to=${MIAOU_BASH_ERROR_CHILDREN}>" |
|
|
|
local i source lineno funcname |
|
|
|
for i in "${tmp_error[@]}"; do >>"$MIAOU_BASH_ERROR_CHILDREN" echo "$i"; done |
|
|
|
for i in "${!error_source[@]}"; do |
|
|
|
source="${error_source[$i]}" |
|
|
|
lineno="${error_lineno[$i]}" |
|
|
|
@ -298,6 +297,7 @@ function save_err_trace_to_main { |
|
|
|
miaou_debug "<trace source=${source} lineno=${lineno} funcname=${funcname}/>" |
|
|
|
>>"$MIAOU_BASH_ERROR_CHILDREN" echo -e "\tmiaou_trace: source=${source} lineno=${lineno} funcname=${funcname}" |
|
|
|
done |
|
|
|
for i in "${tmp_error[@]}"; do >>"$MIAOU_BASH_ERROR_CHILDREN" echo "$i"; done |
|
|
|
miaou_debug "</save_stacktrace_to_stderr>" |
|
|
|
} |
|
|
|
|
|
|
|
@ -323,7 +323,25 @@ function dump_stacktrace { |
|
|
|
function load_tmp_error { |
|
|
|
miaou_debug "<load_tmp_error from=$MIAOU_BASH_ERROR>" |
|
|
|
if [[ ! -v tmp_error ]]; then |
|
|
|
local count count_children tmp_error_children |
|
|
|
if [[ -f "$MIAOU_BASH_ERROR_CURRENT_CHILDREN" ]]; then |
|
|
|
miaou_debug "<tmp_children found=$MIAOU_BASH_ERROR_CURRENT_CHILDREN>" |
|
|
|
mapfile -t tmp_error_children <"$MIAOU_BASH_ERROR_CURRENT_CHILDREN" |
|
|
|
local count_children=${#tmp_error_children[@]} |
|
|
|
if [[ $count_children == 0 ]]; then |
|
|
|
miaou_debug "<tmp_error_children empty/>" |
|
|
|
else |
|
|
|
miaou_debug "<tmp_error_children count=${count_children}>" |
|
|
|
fi |
|
|
|
miaou_debug "</tmp_children>" |
|
|
|
rm "$MIAOU_BASH_ERROR_CURRENT_CHILDREN" |
|
|
|
fi |
|
|
|
|
|
|
|
mapfile -t tmp_error <"$MIAOU_BASH_ERROR" |
|
|
|
|
|
|
|
if [[ -v count_children && $count_children -gt 0 ]]; then |
|
|
|
tmp_error=("${tmp_error[@]}" "${tmp_error_children[@]}") |
|
|
|
fi |
|
|
|
local count=${#tmp_error[@]} |
|
|
|
if [[ $count == 0 ]]; then |
|
|
|
miaou_debug "<tmp_error empty/>" |
|
|
|
@ -448,21 +466,18 @@ function build_miaou_bash_error { |
|
|
|
[[ -f "${directory}/${PPID}.tmp" ]] && CHILD_PROCESS=true |
|
|
|
|
|
|
|
mkdir -p "$directory" |
|
|
|
if is_true $CHILD_PROCESS; then |
|
|
|
MIAOU_BASH_ERROR_CHILDREN="${directory}/${PPID}.children.tmp" |
|
|
|
fi |
|
|
|
MIAOU_BASH_ERROR_CURRENT_CHILDREN="${directory}/$$.children.tmp" |
|
|
|
MIAOU_BASH_ERROR_CHILDREN="${directory}/${PPID}.children.tmp" |
|
|
|
MIAOU_BASH_ERROR="${directory}/$$.tmp" |
|
|
|
rm -f "$MIAOU_BASH_ERROR" |
|
|
|
|
|
|
|
readonly MIAOU_BASH_ERROR_CHILDREN MIAOU_BASH_ERROR CHILD_PROCESS |
|
|
|
readonly MIAOU_BASH_ERROR_CURRENT_CHILDREN MIAOU_BASH_ERROR_CHILDREN MIAOU_BASH_ERROR CHILD_PROCESS |
|
|
|
} |
|
|
|
|
|
|
|
function cleanup { |
|
|
|
if ! is_true $CHILD_PROCESS; then |
|
|
|
miaou_debug '<cleanup main/>' |
|
|
|
trap - ERR EXIT PIPE RETURN |
|
|
|
# rm "$MIAOU_BASH_ERROR" |
|
|
|
fi |
|
|
|
miaou_debug '<cleanup />' |
|
|
|
trap - ERR EXIT PIPE RETURN |
|
|
|
rm -f "$MIAOU_BASH_ERROR" |
|
|
|
} |
|
|
|
|
|
|
|
## main |
|
|
|
|