From fa074cf0c8cd66b3b79de5d691fe8c6109fc96db Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Apr 07 2021 22:35:34 +0000 Subject: 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. (cherry picked from commit a22318e55492af721879d8692ed039144696bb08) Related: #1689832 patch_name: 0127-format-table-before-outputting-a-color-check-if-colo.patch present_in_specfile: true location_in_specfile: 127 squash_commits: true --- diff --git a/src/basic/format-table.c b/src/basic/format-table.c index ac5d66e..17be728 100644 --- a/src/basic/format-table.c +++ b/src/basic/format-table.c @@ -1255,13 +1255,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);