test TYPE: FALSE

This commit is contained in:
pvincent
2026-07-18 01:25:01 +04:00
parent 89f2bece87
commit 9d3652a655
3 changed files with 11 additions and 5 deletions
+7 -4
View File
@@ -8,6 +8,10 @@ readonly MIAOU_BASH_ERROR MIAOU_BASH_DEBUG
# FUNCTIONS # FUNCTIONS
function is_true {
[[ "${1,,}" =~ ^(true|yes|1)$ ]]
}
# overridden function which permits backtracing of original `return` statement # overridden function which permits backtracing of original `return` statement
function false { function false {
>&2 echo "${BASH_SOURCE[1]}:${BASH_LINENO[0]} false" >&2 echo "${BASH_SOURCE[1]}:${BASH_LINENO[0]} false"
@@ -178,8 +182,7 @@ function on_exit {
} }
function debug { function debug {
[[ "${MIAOU_BASH_DEBUG}" == true ]] && >/dev/tty echo "*********** DEBUG: $*" || is_true "${MIAOU_BASH_DEBUG}" && >/dev/tty echo "*********** DEBUG: $*" || true
true
} }
function dump_failure { function dump_failure {
@@ -206,9 +209,9 @@ function dump_failure {
function dump_stderr { function dump_stderr {
last_trim=${1:-false} last_trim=${1:-false}
mapfile -t tmp_error <"$MIAOU_BASH_ERROR" mapfile -t tmp_error <"$MIAOU_BASH_ERROR"
$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
$MIAOU_BASH_DEBUG && >/dev/tty echo '---stderr---' debug '---stderr---'
for i in "${tmp_error[@]}"; do for i in "${tmp_error[@]}"; do
>&4 echo -e "$i" >&4 echo -e "$i"
done done
+3
View File
@@ -1,3 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# do not use miaou-bash as the shebang
./test/stub/scenario.bash success >/dev/null
[[ $(./test/stub/scenario.bash unbound_variable 2>&1 1>/dev/null) =~ 'TYPE: UNBOUND VARIABLE' ]] [[ $(./test/stub/scenario.bash unbound_variable 2>&1 1>/dev/null) =~ 'TYPE: UNBOUND VARIABLE' ]]
[[ $(./test/stub/scenario.bash false 2>&1 1>/dev/null) =~ 'TYPE: FALSE' ]]
+1 -1
View File
@@ -30,7 +30,7 @@ function do_success {
source "${MIAOU_BASH_DIR}/lib/ansi.bash" source "${MIAOU_BASH_DIR}/lib/ansi.bash"
local content local content
content=$(PADDING_LEFT=2 PADDING_RIGHT=6 style_padding 'this is success') content=$(PADDING_LEFT=2 PADDING_RIGHT=6 style_padding 'this is success')
content=$(FG=PURPLE BG=GRAY style_ansi "$content") content=$(FG=YELLOW BG=BLUE style_ansi "$content")
FG=BLACK BG=RED PADDING=8 style_block "$content" FG=BLACK BG=RED PADDING=8 style_block "$content"
} }