commit 127bc7585c0fa224f9698d32dd8d5b71e25ba9a4 parent ebdb45dde4984e7ccd471b226ed99c44b6793569 Author: Kyle Milz <kyle@getaddrinfo.net> Date: Thu, 12 Mar 2015 02:58:55 -0600 PriceChart: be smarter about tty detection Diffstat:
M | PriceChart.pm | | | 9 | ++++----- |
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/PriceChart.pm b/PriceChart.pm @@ -130,14 +130,13 @@ sub get_log # sub trunc_line { - my $line = shift; + my $line = shift || return undef; my $prefix = shift || 0; - my $term_width = 80; - if (POSIX::isatty(STDOUT)) { - ($term_width) = Term::ReadKey::GetTerminalSize(); - } + # if stdout is not a tty, it's likely a log file, output everything + return $line unless (POSIX::isatty(STDOUT)); + my ($term_width) = Term::ReadKey::GetTerminalSize(); my $len = $term_width - $prefix - 3; if (length($line) < $len) { return $line;