From 0d68f61442b477b5f474fcb83aab6b4a4b620bb4 Mon Sep 17 00:00:00 2001 From: pvincent Date: Thu, 30 Jul 2026 18:26:59 +0400 Subject: [PATCH] hint ok --- bin/miaou-bash | 11 +++++++++-- test/stub/scenario.bash | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/miaou-bash b/bin/miaou-bash index 1913f8c..65f944c 100755 --- a/bin/miaou-bash +++ b/bin/miaou-bash @@ -178,7 +178,6 @@ function on_error { source="${BASH_REMATCH[1]}" lineno="${BASH_REMATCH[2]}" funcname="${BASH_REMATCH[3]}" - [[ "$funcname" == '
' ]] && funcname="$funcname (hint: prefer source than child process)" extra_source=("$source") extra_lineno=("$lineno") extra_funcname=("$funcname") @@ -191,7 +190,6 @@ function on_error { source="${BASH_REMATCH[1]}" lineno="${BASH_REMATCH[2]}" funcname="${BASH_REMATCH[3]}" - [[ "$funcname" == '
' ]] && funcname="$funcname (hint: prefer source than child process)" extra_source=("$source" "${extra_source[@]}") extra_lineno=("$lineno" "${extra_lineno[@]}") extra_funcname=("$funcname" "${extra_funcname[@]}") @@ -234,6 +232,15 @@ function on_error { error_source=("${extra_source[@]}" "${error_source[@]}") error_lineno=("${extra_lineno[@]}" "${error_lineno[@]}") error_funcname=("${extra_funcname[@]}" "${error_funcname[@]}") + + # add the funcname hint message from backward + local funcname hint_for_next=false + for ((i = 0; i < ${#error_funcname[@]}; i++)); do + is_true "$hint_for_next" && error_funcname[$i]+=' (hint: prefer source than child process)' && hint_for_next=false + funcname="${error_funcname[$i]}" + [[ "$funcname" == '
' ]] && hint_for_next=true || true + done + else error_source=("${error_source[@]}") error_lineno=("${error_lineno[@]}") diff --git a/test/stub/scenario.bash b/test/stub/scenario.bash index 97a5bfd..bb61bf0 100755 --- a/test/stub/scenario.bash +++ b/test/stub/scenario.bash @@ -91,8 +91,8 @@ function do_file_not_found { } function do_child_error { - "$BASEDIR/extra/library.bash" # . "$BASEDIR/extra/library.bash" + "$BASEDIR/extra/library.bash" echo SHOULD NOT APPEAR }