You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

29 lines
585 B

#!/usr/bin/env -S -- bash
function on_exit {
code=${1:-0}
echo ON_EXIT2 $code
[[ -s /tmp/error ]] && cat /tmp/error
trap - ERR TERM INT EXIT
builtin exit $code
}
echo BASH_STRICT $@
echo ----------
command=$1
shift
args=("$@")
args2=()
for i in "${args[@]}"; do
echo ARG: $i
args2+=("${i@Q}")
done
echo "----$command ${args2[@]}------"
set -TEue -o pipefail
export -f on_exit
echo PROCESS START
bash -c "set -TEue -o pipefail; trap 'on_exit \$?' ERR TERM INT EXIT; source $command ${args2[*]}" 3>&1 1>&2 2>&3 | tee /tmp/error
echo PROCESS END succesfully