e2ec8a
From 02b72c15a53f694f65a377206fba478db91432cd Mon Sep 17 00:00:00 2001
e2ec8a
From: Lennart Poettering <lennart@poettering.net>
e2ec8a
Date: Tue, 6 Nov 2018 18:37:21 +0100
e2ec8a
Subject: [PATCH] format-table: before outputting a color, check if colors are
e2ec8a
 available
e2ec8a
e2ec8a
This is in many cases redundant, as a similar check is done by various
e2ec8a
callers already, but in other cases (where we read the color from a
e2ec8a
static table for example), it's nice to let the color check be done by
e2ec8a
the table code itself, and since it doesn't hurt in the other cases just
e2ec8a
do it again.
e2ec8a
e2ec8a
(cherry picked from commit a22318e55492af721879d8692ed039144696bb08)
e2ec8a
e2ec8a
Related: #1689832
e2ec8a
---
e2ec8a
 src/basic/format-table.c | 6 +++---
e2ec8a
 1 file changed, 3 insertions(+), 3 deletions(-)
e2ec8a
e2ec8a
diff --git a/src/basic/format-table.c b/src/basic/format-table.c
e2ec8a
index ac5d66eda2..17be7285cd 100644
e2ec8a
--- a/src/basic/format-table.c
e2ec8a
+++ b/src/basic/format-table.c
e2ec8a
@@ -1255,13 +1255,13 @@ int table_print(Table *t, FILE *f) {
e2ec8a
                         if (j > 0)
e2ec8a
                                 fputc(' ', f); /* column separator */
e2ec8a
 
e2ec8a
-                        if (d->color)
e2ec8a
+                        if (d->color && colors_enabled())
e2ec8a
                                 fputs(d->color, f);
e2ec8a
 
e2ec8a
                         fputs(field, f);
e2ec8a
 
e2ec8a
-                        if (d->color)
e2ec8a
-                                fputs(ansi_normal(), f);
e2ec8a
+                        if (d->color && colors_enabled())
e2ec8a
+                                fputs(ANSI_NORMAL, f);
e2ec8a
                 }
e2ec8a
 
e2ec8a
                 fputc('\n', f);