|
|
@ -65,19 +65,21 @@ function on_exit { |
|
|
regex=': unbound variable$' |
|
|
regex=': unbound variable$' |
|
|
[[ $code == 1 ]] && [[ "$message" =~ $regex ]] && stack_lines[0]=$line |
|
|
[[ $code == 1 ]] && [[ "$message" =~ $regex ]] && stack_lines[0]=$line |
|
|
|
|
|
|
|
|
regex="^return [0-9]* from (.*)\$" |
|
|
|
|
|
|
|
|
regex="^return ([0-9]*) from (.*)\$" |
|
|
if [[ "$message" =~ $regex ]]; then |
|
|
if [[ "$message" =~ $regex ]]; then |
|
|
funcname="${BASH_REMATCH[1]}" |
|
|
|
|
|
|
|
|
return_code="${BASH_REMATCH[1]}" |
|
|
|
|
|
funcname="${BASH_REMATCH[2]}" |
|
|
# >&4 echo "RETURN DETECTED line ${stack_sources[0]} $line $funcname" |
|
|
# >&4 echo "RETURN DETECTED line ${stack_sources[0]} $line $funcname" |
|
|
stack_sources=("${stack_sources[0]}" "${stack_sources[@]}") |
|
|
stack_sources=("${stack_sources[0]}" "${stack_sources[@]}") |
|
|
stack_lines=("$line" "${stack_lines[@]}") |
|
|
stack_lines=("$line" "${stack_lines[@]}") |
|
|
stack_functions=("$funcname" "${stack_functions[@]}") |
|
|
stack_functions=("$funcname" "${stack_functions[@]}") |
|
|
fi |
|
|
|
|
|
|
|
|
stack_summary+=("ERROR $code: [return $return_code]") |
|
|
|
|
|
else |
|
|
stack_summary+=("ERROR $code: [$message]") |
|
|
stack_summary+=("ERROR $code: [$message]") |
|
|
|
|
|
fi |
|
|
else |
|
|
else |
|
|
# TODO: if last_error is a detected stacktrace, grab as so |
|
|
|
|
|
# pstree -as $$ => parent contains bash-back? |
|
|
|
|
|
stack_summary+=("ERROR $code: <undefined>") |
|
|
|
|
|
|
|
|
regex=' .*:[0-9]* .*' |
|
|
|
|
|
[[ "$last_error" =~ $regex ]] || stack_summary+=("ERROR $code: <undefined>") |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
for i in "${!stack_functions[@]}"; do |
|
|
for i in "${!stack_functions[@]}"; do |
|
|
|