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

Petr Vorel pvorel@suse.cz
Mon Aug 8 13:12:13 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=$?
OK, this is not working for LTP_COLORIZE_OUTPUT=n => v4 will come shortly.

Kind regards,
Petr

>  	[ "$color" = "1" ] && tst_flag2color "$1"
>  	printf "$2"


More information about the ltp mailing list