Browse Source

subshell_term error ok

main
pvincent 4 days ago
parent
commit
1955ae5b23
  1. 25
      bin/miaou-bash
  2. 2
      test/stub/scenario.bash

25
bin/miaou-bash

@ -95,6 +95,7 @@ function on_exit {
failure_payload="${BASH_REMATCH[2]}" failure_payload="${BASH_REMATCH[2]}"
fi fi
last_error="${BASH_SOURCE[1]}:${BASH_LINENO[0]} subshell term $code" last_error="${BASH_SOURCE[1]}:${BASH_LINENO[0]} subshell term $code"
printf "\r"
kill -USR1 $$ kill -USR1 $$
else else
failure_type='UNKNOWN' failure_type='UNKNOWN'
@ -217,9 +218,12 @@ function ansi_block_error {
content=$(style_padding "$content") content=$(style_padding "$content")
detail=$(BG=BLACK style_padding "$2") detail=$(BG=BLACK style_padding "$2")
exit_code=$(FG=CYAN style_ansi " $3") 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 ansi_reset
FG=RED style_ansi " ║"
echo
} }
function ansi_traces { function ansi_traces {
@ -229,31 +233,31 @@ function ansi_traces {
declare -n functions=$3 declare -n functions=$3
optional=false optional=false
for i in "${!sources[@]}"; do 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" && 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") location=$(STYLE=ITALIC style_ansi "$location")
printf "%40s\t%s\n" "${location}" "${functions[$i]}"
builtin echo "${location} ${functions[$i]}"
optional=true optional=true
done done
} }
function dump_failure { function dump_failure {
declare -F style_ansi >/dev/null || source "$MIAOU_BASH_DIR/lib/ansi.bash"
dump_stderr true dump_stderr true
debug '---stacktrace---'
if [[ ${failure_type} == 'SUBSHELL SOURCE NOT FOUND' ]]; then if [[ ${failure_type} == 'SUBSHELL SOURCE NOT FOUND' ]]; then
: :
else else
debug '---error---'
if [[ $failure_type == 'SUBSHELL ERROR' ]]; then if [[ $failure_type == 'SUBSHELL ERROR' ]]; then
>&4 echo -e "${failure_payload}" >&4 echo -e "${failure_payload}"
else 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_error "$failure_type" "$failure_payload" "$code"
>&4 ansi_block_continuation
fi fi
debug '---end of error---'
fi 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 >&4 ansi_traces stack_sources stack_lines stack_functions
# for i in "${failure_traces[@]}"; do # 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[@]}") is_true "$last_trim" && unset 'tmp_error[-1]' && tmp_error=("${tmp_error[@]}")
if [[ "${#tmp_error[@]}" -gt 0 ]]; then if [[ "${#tmp_error[@]}" -gt 0 ]]; then
debug '---stderr---' debug '---stderr---'
>&4 printf '\r'
for i in "${tmp_error[@]}"; do for i in "${tmp_error[@]}"; do
>&4 echo -e "$i" >&4 echo -e "$i"
done done

2
test/stub/scenario.bash

@ -8,6 +8,7 @@ readonly BASEDIR
# SCENARII # SCENARII
function do_subshell_false { function do_subshell_false {
echo 'about to echo false'
result=$(false) result=$(false)
} }
@ -37,6 +38,7 @@ function do_unbound_associative {
function do_false { function do_false {
echo before false echo before false
echo -n 'paragraph...'
false false
echo after false echo after false
} }

Loading…
Cancel
Save