From c750b11c7eec884ccbd638e1a76f4d799e948a58 Mon Sep 17 00:00:00 2001 From: Dan Church Date: Mon, 14 Dec 2020 10:19:28 -0600 Subject: [PATCH] Update test Make sure to print when a control character is present. If it doesn't, it leads to confusion when bash reports two apparently-equal strings don't actually match due to the presence of a non-printing character. --- t/funcs.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/t/funcs.sh b/t/funcs.sh index d336424..d25804c 100644 --- a/t/funcs.sh +++ b/t/funcs.sh @@ -4,25 +4,29 @@ echo_success() { printf '[\033[1;32m%s\033[0;39m] %s' \ ' OK ' \ - "$*" + "$(escape_nonprinting "$*")" } echo_failure() { printf '[\033[1;31m%s\033[0;39m] %s' \ 'FAILED' \ - "$*" + "$(escape_nonprinting "$*")" } echo_warning() { printf '[\033[1;33m%s\033[0;39m] %s' \ 'WARNING' \ - "$*" + "$(escape_nonprinting "$*")" } echo_passed() { printf '[\033[1;33m%s\033[0;39m] %s' \ 'PASSED' \ - "$*" + "$(escape_nonprinting "$*")" +} + +escape_nonprinting() { + echo "$*" |cat -v } assert_equals() {