From: Lennart Poettering Date: Tue, 6 Nov 2018 17:37:21 +0000 (+0100) Subject: format-table: before outputting a color, check if colors are available X-Git-Tag: v240~167^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a22318e55492af721879d8692ed039144696bb08;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/shared/format-table.c b/src/shared/format-table.c index a99f1cff3c5..959bfc53c4f 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);