1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-26 03:22:00 +03:00

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.
This commit is contained in:
Lennart Poettering 2018-11-06 18:37:21 +01:00
parent 165ca5663e
commit a22318e554

View File

@ -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);