From 1955ae5b23545d67d1786a5139ecdcd9ca3f496a Mon Sep 17 00:00:00 2001 From: pvincent Date: Tue, 21 Jul 2026 17:32:56 +0400 Subject: [PATCH] subshell_term error ok --- bin/miaou-bash | 25 +++++++++++++++---------- test/stub/scenario.bash | 2 ++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/bin/miaou-bash b/bin/miaou-bash index 35f4e45..cdbbf94 100755 --- a/bin/miaou-bash +++ b/bin/miaou-bash @@ -95,6 +95,7 @@ function on_exit { failure_payload="${BASH_REMATCH[2]}" fi last_error="${BASH_SOURCE[1]}:${BASH_LINENO[0]} subshell term $code" + printf "\r" kill -USR1 $$ else failure_type='UNKNOWN' @@ -217,9 +218,12 @@ function ansi_block_error { content=$(style_padding "$content") detail=$(BG=BLACK style_padding "$2") exit_code=$(FG=CYAN style_ansi " $3") - style_block "$content$detail$exit_code" - + printf "\r" + BLOCK_CONTINUATION_COL=5 style_block "$content$detail$exit_code" + # echo "$content$detail$exit_code" ansi_reset + FG=RED style_ansi " ║" + echo } function ansi_traces { @@ -229,31 +233,31 @@ function ansi_traces { declare -n functions=$3 optional=false for i in "${!sources[@]}"; do - FG=RED style_ansi "\t╟─⟶" - location="${sources[$i]}:${lines[$i]}" + FG=RED style_ansi " ╟─⟶" + location=$(printf "%40s" "${sources[$i]}:${lines[$i]}") is_true "$optional" && - location=$(FG=GRAY STYLE=ITALIC style_ansi "\t$location") || # FIXME: \t should not be required! + location=$(FG=GRAY STYLE=ITALIC style_ansi "$location") || location=$(STYLE=ITALIC style_ansi "$location") - printf "%40s\t%s\n" "${location}" "${functions[$i]}" + builtin echo "${location} ${functions[$i]}" optional=true done } function dump_failure { + declare -F style_ansi >/dev/null || source "$MIAOU_BASH_DIR/lib/ansi.bash" dump_stderr true - debug '---stacktrace---' if [[ ${failure_type} == 'SUBSHELL SOURCE NOT FOUND' ]]; then : else + debug '---error---' if [[ $failure_type == 'SUBSHELL ERROR' ]]; then >&4 echo -e "${failure_payload}" else - declare -F style_ansi >/dev/null || source "$MIAOU_BASH_DIR/lib/ansi.bash" >&4 ansi_block_error "$failure_type" "$failure_payload" "$code" - >&4 ansi_block_continuation fi + debug '---end of error---' fi - declare -F style_ansi >/dev/null || source "$MIAOU_BASH_DIR/lib/ansi.bash" + debug '---stacktrace---' >&4 ansi_traces stack_sources stack_lines stack_functions # for i in "${failure_traces[@]}"; do @@ -269,6 +273,7 @@ function dump_stderr { is_true "$last_trim" && unset 'tmp_error[-1]' && tmp_error=("${tmp_error[@]}") if [[ "${#tmp_error[@]}" -gt 0 ]]; then debug '---stderr---' + >&4 printf '\r' for i in "${tmp_error[@]}"; do >&4 echo -e "$i" done diff --git a/test/stub/scenario.bash b/test/stub/scenario.bash index eaaa898..0ecda1b 100755 --- a/test/stub/scenario.bash +++ b/test/stub/scenario.bash @@ -8,6 +8,7 @@ readonly BASEDIR # SCENARII function do_subshell_false { + echo 'about to echo false' result=$(false) } @@ -37,6 +38,7 @@ function do_unbound_associative { function do_false { echo before false + echo -n 'paragraph...' false echo after false }