poc starting1

This commit is contained in:
pvincent
2026-07-26 11:08:11 +04:00
parent 98deda9e6c
commit 473bed362e
2 changed files with 53 additions and 2 deletions
Executable
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# constants
## functions
function on_error {
code="${1:-0}"
>&2 echo on_error: $$ $BASHPID
if [[ $$ == "$BASHPID" ]]; then
>&2 echo "${BASH_SOURCE[1]}: line ${BASH_LINENO[0]}: command_error: ${code}"
exit "$code"
else
>&2 echo "${BASH_SOURCE[1]}: line ${BASH_LINENO[0]}: subshell_error: ${code}"
kill -PIPE $$
fi
# kill -INT $BASHPID
# kill -INT $$
}
function on_exit {
code="${1:-0}"
echo "on_exit $code"
}
function on_pipe {
>&2 echo on_pipe: $$ $BASHPID
#TODO: compute code from latest sterr in case of command_error
code="${1:-24}" # 24 => CTRL-C
trap - EXIT ERR PIPE
exit "$code"
}
## main
set -euo pipefail
set -T # DEBUG RETURN
set -E # ERR on subshell
# set -b
trap 'on_error $?' ERR
trap 'on_exit $?' EXIT
trap 'on_pipe' PIPE
echo "${BASHPID}"
source ./test/stub/scenario.bash subshell_term
+5 -2
View File
@@ -13,8 +13,11 @@ function do_subshell_false {
}
function do_subshell_term {
echo "found2=$(grep nope nope)"
echo "found1=$(command_not_found)"
# grep none none
echo "found1=$(grep nope nope)"
echo "found2=$(command_not_found)"
echo SHOULD NOT SHOW UP!
}