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

15
useless.sh

@ -1,11 +1,22 @@
#!/bin/bash
function F2 {
echo "stdout A"
# echo toto >>/tmp/toto
# $nope
grep titi toto
# exit 6
>&2 echo "This is stderr"
echo "stdout B"
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