diff options
author | Karel Zak | 2013-02-19 14:10:24 +0100 |
---|---|---|
committer | Karel Zak | 2013-02-19 14:10:24 +0100 |
commit | 3785056ca8115d4c0b402abf788219be6203ebb3 (patch) | |
tree | 73b4b393b25cca67a04c59904801cec23cab44b5 /lib | |
parent | libblkid: add blkid_probe_step_back to documentation (diff) | |
download | kernel-qcow2-util-linux-3785056ca8115d4c0b402abf788219be6203ebb3.tar.gz kernel-qcow2-util-linux-3785056ca8115d4c0b402abf788219be6203ebb3.tar.xz kernel-qcow2-util-linux-3785056ca8115d4c0b402abf788219be6203ebb3.zip |
lib/tty: don't truncate output on non-terminals
for example:
$ findmnt | cat
$ lslocks > foo
the output should not be truncated.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tt.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -535,6 +535,9 @@ static void recount_widths(struct tt *tb, char *buf, size_t bufsz) extremes += cl->is_extreme; } + if (!tb->is_term) + return; + /* reduce columns with extreme fields */ if (width > tb->termwidth && extremes) { @@ -874,8 +877,11 @@ int tt_print_table(struct tt *tb) if (!tb) return -1; - if (tb->first_run && !tb->termwidth) { - tb->termwidth = get_terminal_width(); + if (tb->first_run) { + tb->is_term = isatty(STDOUT_FILENO); + + if (tb->is_term && !tb->termwidth) + tb->termwidth = get_terminal_width(); if (tb->termwidth <= 0) tb->termwidth = 80; } |