[LTP] [PATCH v3 2/4] tst_ansi_color.sh: Allow to run with set -e

Petr Vorel pvorel@suse.cz
Mon Aug 8 12:10:17 CEST 2022


set -e (or #!/bin/sh -e or set -o errexit) quits on any non-zero exit
code, harden tst_res TINFO to be able to be used on scripts with it.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_ansi_color.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/testcases/lib/tst_ansi_color.sh b/testcases/lib/tst_ansi_color.sh
index 703df1eb8..4b2255448 100644
--- a/testcases/lib/tst_ansi_color.sh
+++ b/testcases/lib/tst_ansi_color.sh
@@ -32,8 +32,9 @@ tst_color_enabled()
 
 tst_print_colored()
 {
-	tst_color_enabled
-	local color=$?
+	local color=0
+
+	tst_color_enabled || color=$?
 
 	[ "$color" = "1" ] && tst_flag2color "$1"
 	printf "$2"
-- 
2.37.1



More information about the ltp mailing list