Merge pull request #13936 from keszybz/format-table-uninhibited

Output tables at full width if piped
This commit is contained in:
Anita Zhang
2019-11-05 15:03:15 -08:00
committed by GitHub
3 changed files with 23 additions and 10 deletions
+6 -3
View File
@@ -2,6 +2,7 @@
#include <ctype.h>
#include <net/if.h>
#include <unistd.h>
#include "alloc-util.h"
#include "fd-util.h"
@@ -1611,10 +1612,12 @@ int table_print(Table *t, FILE *f) {
}
/* Calculate effective table width */
if (t->width == (size_t) -1)
table_effective_width = pager_have() ? table_requested_width : MIN(table_requested_width, columns());
else
if (t->width != (size_t) -1)
table_effective_width = t->width;
else if (pager_have() || !isatty(STDOUT_FILENO))
table_effective_width = table_requested_width;
else
table_effective_width = MIN(table_requested_width, columns());
if (table_maximum_width != (size_t) -1 && table_effective_width > table_maximum_width)
table_effective_width = table_maximum_width;