From 490d7bbf5c2c24ec3917268bd122cf685bca2c4e Mon Sep 17 00:00:00 2001 From: pvincent Date: Wed, 8 Jul 2026 00:08:33 +0400 Subject: [PATCH] opt_debug --- bin/bash-strict | 10 ++++++++-- test5.sh | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/bash-strict b/bin/bash-strict index 27b2beb..9e833d4 100755 --- a/bin/bash-strict +++ b/bin/bash-strict @@ -27,7 +27,9 @@ function exit { # MAIN -# TODO: take attention to argument like -x or --debug, then shift! +opt_debug="" +[[ $1 == '-x' || $1 == '--debug' ]] && opt_debug="-x" && shift + command=$1 shift original_args=("$@") @@ -37,6 +39,10 @@ for i in "${original_args[@]}"; do quoted_args+=("${i@Q}"); done set -TEue -o pipefail export -f exit # 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 diff --git a/test5.sh b/test5.sh index 99d463a..8696fa7 100755 --- a/test5.sh +++ b/test5.sh @@ -1,5 +1,4 @@ -#!/usr/bin/bash-strict -##!/usr/bin/env -S -- bash-strict +#!/usr/bin/env -S -- bash-strict function f2 { # return 6