#include <ctype.h>
#include <net/if.h>
+#include <unistd.h>
#include "alloc-util.h"
#include "fd-util.h"
}
/* 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;
/* SPDX-License-Identifier: LGPL-2.1+ */
+#include <unistd.h>
+
#include "alloc-util.h"
#include "format-table.h"
#include "string-util.h"
assert_se(table_format(t, &formatted) >= 0);
printf("%s\n", formatted);
- assert_se(streq(formatted,
- " no a long f… no a long f… a long fi…\n"
- " no fäää no fäää fäää \n"
- " yes fäää yes fäää fäää \n"
- " yes xxx yes xxx xxx \n"
- "5min 5min \n"));
+ if (isatty(STDOUT_FILENO))
+ assert_se(streq(formatted,
+ " no a long f… no a long f… a long fi…\n"
+ " no fäää no fäää fäää \n"
+ " yes fäää yes fäää fäää \n"
+ " yes xxx yes xxx xxx \n"
+ "5min 5min \n"));
+ else
+ assert_se(streq(formatted,
+ " no a long field no a long field a long field\n"
+ " no fäää no fäää fäää \n"
+ " yes fäää yes fäää fäää \n"
+ " yes xxx yes xxx xxx \n"
+ "5min 5min \n"));
test_issue_9549();