width option fallback to tput
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 23 Sep 2019 18:03:14 +0000 (20:03 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 24 Sep 2019 00:08:51 +0000 (02:08 +0200)
Environment variable is not exported on some systems.

barcat

diff --git a/barcat b/barcat
index 2acdaddfca5c4cf232a67cb35375742fcfaddea4..804b3b074b8c54ba005c61ffdd1ffb32c73b01a4 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -101,7 +101,7 @@ GetOptions(\%opt,
        },
 ) or exit 64;  # EX_USAGE
 
-$opt{width} ||= $ENV{COLUMNS} || 80;
+$opt{width} ||= $ENV{COLUMNS} || qx(tput cols) || 80;
 $opt{color} //= -t *STDOUT;  # enable on tty
 $opt{'graph-format'} //= '-';
 $opt{trim}   *= $opt{width} / 100 if $opt{trimpct};