MIAOU-BASH is a collection of settings and helpers for leveraging BASH. Developer-friendly, it may be used as solo package with or without the miaou project.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

47 lines
1.0 KiB

#!/usr/bin/env miaou-bash
. "$MIAOU_BASH_DIR/lib/ansi.bash"
TYPE='SUBSHELL TERM'
PAYLOAD='blabla'
stack_sources=('file.bash' './lib/utility.bash' 'file.bash')
stack_lines=(18 56 12)
stack_functions=('f2' 'f1' '<main>')
function dump_failure {
BG=RED
FG=BLACK
PADDING=2
content=$(style_ansi "${TYPE}")
content=$(style_padding "$content")
detail=$(BG=BLACK style_padding "${PAYLOAD}")
style_block "$content$detail"
ansi_reset
}
function dump_traces {
local optional location
# block continuation
tput sc
tput cuu 1
BG=RED FG=BLACK style_ansi "\t╦"
tput rc
FG=RED style_ansi "\t║\n"
optional=false
for i in "${!stack_sources[@]}"; do
FG=RED style_ansi "\t╟─⟶"
location="${stack_sources[$i]}:${stack_lines[$i]}"
is_true "$optional" &&
location=$(FG=GRAY STYLE=ITALIC style_ansi "\t$location") || # FIXME: \t should not be required!
location=$(STYLE=ITALIC style_ansi "$location")
printf "%40s\t%s\n" "${location}" "${stack_functions[$i]}"
optional=true
done
}
dump_failure
dump_traces