subshell_term error ok

This commit is contained in:
pvincent
2026-07-21 17:32:56 +04:00
parent 82814771d0
commit 1955ae5b23
2 changed files with 17 additions and 10 deletions
+15 -10
View File
@@ -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
+2
View File
@@ -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
}