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