From: Sebastien GODARD Date: Sat, 13 Jun 2020 09:55:28 +0000 (+0200) Subject: Display statistics in color by default X-Git-Tag: v12.4.0~36 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c845ac8f8da7b4a36139ea07cf92d2390ec043d0;p=sysstat Display statistics in color by default Display statistics in colors by default when the output is connected to a terminal. It is no longer necessary to set the S_COLORS environment variable. Signed-off-by: Sebastien GODARD --- diff --git a/common.c b/common.c index c086f13..03a1c93 100644 --- a/common.c +++ b/common.c @@ -1061,11 +1061,13 @@ void init_colors(void) int len; /* Read S_COLORS environment variable */ - if (((e = __getenv(ENV_COLORS)) == NULL) || - !strcmp(e, C_NEVER) || - (strcmp(e, C_ALWAYS) && !isatty(STDOUT_FILENO))) { + if ((e = __getenv(ENV_COLORS)) == NULL + ? !isatty(STDOUT_FILENO) + : (!strcmp(e, C_NEVER) || + (strcmp(e, C_ALWAYS) && !isatty(STDOUT_FILENO)))) { /* - * Environment variable not set, or set to "never", + * Environment variable not set and stdout is not a terminal, + * or set to "never", * or set to "auto" and stdout is not a terminal: * Unset color strings. */