]> granicus.if.org Git - sysstat/commitdiff
Display statistics in color by default
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 13 Jun 2020 09:55:28 +0000 (11:55 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 13 Jun 2020 09:55:28 +0000 (11:55 +0200)
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 <sysstat@users.noreply.github.com>
common.c

index c086f1387d8dd45a5b3a00ea392e430202cda6d9..03a1c93c36c9947c0d04d9a54f0de57b578f74e4 100644 (file)
--- 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.
                 */