ansi_error

This commit is contained in:
pvincent
2026-07-20 11:53:30 +04:00
parent 560aef5e26
commit 4b91a11d04
6 changed files with 77 additions and 100 deletions
-33
View File
@@ -1,33 +0,0 @@
#!/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>')
BG=RED
FG=BLACK
PADDING=2
content=$(style_ansi "${TYPE}")
content=$(style_padding "$content")
detail=$(BG=BLACK style_padding "${PAYLOAD}")
style_block "$content$detail"
# block continuation
tput sc
tput cuu 1
style_ansi "\t╦"
tput rc
style_ansi "\t║"
echo
for i in "${!stack_sources[@]}"; do
style_ansi "\t╟"
# echo "─⟶ ${sources[$i]}:${lines[$i]} in ${functions[$i]}"
printf "─⟶ %40s\t%s\n" "${stack_sources[$i]}:${stack_lines[$i]}" "${stack_functions[$i]}"
done
-19
View File
@@ -1,19 +0,0 @@
#!/usr/bin/env miaou-bash
function f1 {
if [[ -v nested_count ]]; then
>/dev/tty echo already defined $nested_count
((nested_count++))
else
>/dev/tty echo brand new
nested_count=1
fi
echo $nested_count
}
echo "v=$(f1)"
echo "v=$(f1)"
echo "v=$(f1)"
f1
f1
echo $nested_count
+47
View File
@@ -0,0 +1,47 @@
#!/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
-32
View File
@@ -1,32 +0,0 @@
#!/usr/bin/env miaou-bash
ArrayOfArray_1=("Alan" "24")
ArrayOfArray_2=("Walker" "31")
MainArray=()
array_count=0
array_count=$(( array_count + 1 ))
array_name="array_$array_count"
declare -a "$array_name"
declare -n ref="$array_name"
ref+=("Bernard")
ref+=(46)
MainArray+=(ref[@])
array_count=$(( array_count + 1 ))
array_name="array_$(( array_count + 1 ))"
declare -a "$array_name"
declare -n ref2="$array_name"
ref2+=("Ferland")
ref2+=(17)
MainArray+=(ref2[@])
for sub_array in "${MainArray[@]}"; do
elements=("${!sub_array}") # Get the elements of the sub-array
name=${elements[0]}
age=${elements[1]}
echo "${name,,} $age"
done