Browse Source

no use of pstree because too slow

main
pvincent 1 week ago
parent
commit
4c7605f4a2
  1. 14
      bin/bash-back
  2. 6
      lib/utility.bash
  3. 2
      useless.sh

14
bin/bash-back

@ -65,19 +65,21 @@ function on_exit {
regex=': unbound variable$'
[[ $code == 1 ]] && [[ "$message" =~ $regex ]] && stack_lines[0]=$line
regex="^return [0-9]* from (.*)\$"
regex="^return ([0-9]*) from (.*)\$"
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"
stack_sources=("${stack_sources[0]}" "${stack_sources[@]}")
stack_lines=("$line" "${stack_lines[@]}")
stack_functions=("$funcname" "${stack_functions[@]}")
fi
stack_summary+=("ERROR $code: [return $return_code]")
else
stack_summary+=("ERROR $code: [$message]")
fi
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
for i in "${!stack_functions[@]}"; do

6
lib/utility.bash

@ -8,12 +8,12 @@ function blabla {
}
function suite {
command_not_found
echo $nope
return
exit
return 7
exit 10 # youpi
exit
command_not_found
return
}
blabla

2
useless.sh

@ -31,8 +31,8 @@ function F3 {
echo start of useless
F3
. lib/utility.bash
lib/utility.bash
# . lib/utility.bash
# >&2 echo some trace in stderr
main

Loading…
Cancel
Save