Browse Source

stacktrace starting...

main
pvincent 2 weeks ago
parent
commit
285d318dc0
  1. 12
      bin/bash-strict2.sh
  2. 15
      useless.sh

12
bin/bash-strict2.sh

@ -19,6 +19,15 @@ function exit {
$DEBUG && >/dev/tty echo '---stderr---' $DEBUG && >/dev/tty echo '---stderr---'
>&4 echo "DETECTED: [$content]" >&4 echo "DETECTED: [$content]"
fi fi
stack_lines=("${BASH_LINENO[@]}")
stack_functions=("${FUNCNAME[@]}")
stack_sources=("${BASH_SOURCE[@]}")
echo "${stack_lines[@]}"
echo "${stack_functions[@]}"
echo "${stack_sources[@]}"
cleanup ${code} cleanup ${code}
} }
@ -35,6 +44,7 @@ function cleanup {
$DEBUG && >/dev/tty echo "---exit $1---" $DEBUG && >/dev/tty echo "---exit $1---"
trap - ERR TERM INT EXIT trap - ERR TERM INT EXIT
rm $TMP_ERROR rm $TMP_ERROR
exec 3>&- 4>&-
builtin exit $code builtin exit $code
} }
@ -42,11 +52,9 @@ function cleanup {
set -TEue -o pipefail set -TEue -o pipefail
trap 'exit $?' ERR TERM INT EXIT trap 'exit $?' ERR TERM INT EXIT
# export -f exit
# magic FD # magic FD
exec 3>$TMP_ERROR 4>/dev/stderr exec 3>$TMP_ERROR 4>/dev/stderr
$DEBUG && >/dev/tty echo '---stdout---' $DEBUG && >/dev/tty echo '---stdout---'
source $SCRIPT 2>&3 source $SCRIPT 2>&3
exec 3>&- 4>&-
success success

15
useless.sh

@ -1,11 +1,22 @@
#!/bin/bash #!/bin/bash
function F2 {
echo "stdout A" echo "stdout A"
# echo toto >>/tmp/toto # echo toto >>/tmp/toto
# $nope # $nope
grep titi toto
# exit 6 # exit 6
>&2 echo "This is stderr" >&2 echo "This is stderr"
echo "stdout B" echo "stdout B"
echo "stdout C" echo "stdout C"
command_not_found
echo END of useless
# command_not_found
}
function F1 {
echo F1
F2
}
echo start of useless
F1
echo end of useless
Loading…
Cancel
Save