Browse Source

opt_debug

main
pvincent 2 weeks ago
parent
commit
490d7bbf5c
  1. 10
      bin/bash-strict
  2. 3
      test5.sh

10
bin/bash-strict

@ -27,7 +27,9 @@ function exit {
# MAIN # MAIN
# TODO: take attention to argument like -x or --debug, then shift!
opt_debug=""
[[ $1 == '-x' || $1 == '--debug' ]] && opt_debug="-x" && shift
command=$1 command=$1
shift shift
original_args=("$@") original_args=("$@")
@ -37,6 +39,10 @@ for i in "${original_args[@]}"; do quoted_args+=("${i@Q}"); done
set -TEue -o pipefail set -TEue -o pipefail
export -f exit export -f exit
# echo PROCESS START # echo PROCESS START
bash -c "set -TEue -o pipefail; trap 'exit \$? $TMP_ERROR' ERR TERM INT EXIT; source $command ${quoted_args[*]}" 3>&1 1>&2 2>&3 | tee $TMP_ERROR
bash $opt_debug -c "
set -TEue -o pipefail;
trap 'exit \$? $TMP_ERROR' ERR TERM INT EXIT;
source $command ${quoted_args[*]}
" 3>&1 1>&2 2>&3 | tee $TMP_ERROR
# echo PROCESS END succesfully # echo PROCESS END succesfully

3
test5.sh

@ -1,5 +1,4 @@
#!/usr/bin/bash-strict
##!/usr/bin/env -S -- bash-strict
#!/usr/bin/env -S -- bash-strict
function f2 { function f2 {
# return 6 # return 6

Loading…
Cancel
Save