From 89129d8a812bbfb515b36b016102a133cfe4d19e Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Thu, 9 Jun 2016 19:41:17 +0200 Subject: [PATCH] Detect whether STDOUT is a tty unless --force-oolor is given --- src/InfoCon/buch/vorsteueranmeldung | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/InfoCon/buch/vorsteueranmeldung b/src/InfoCon/buch/vorsteueranmeldung index 94c0949..9429ca2 100755 --- a/src/InfoCon/buch/vorsteueranmeldung +++ b/src/InfoCon/buch/vorsteueranmeldung @@ -31,6 +31,7 @@ use constant CONFIG => '/etc/infocon.cfg'; my $opt_mode = 'month'; my $opt_nocolor = 0; +my $opt_forcecolor = 0; my $opt_start; my $opt_end; my $cfg; @@ -275,6 +276,7 @@ GetOptions ('help|h' => \&help, 'quarter|q' => sub {$opt_mode = 'quarter'}, 'month|m' => sub {$opt_mode = 'month'}, 'no-color|nocolor|raw' => \$opt_nocolor, + 'force-color' => \$opt_forcecolor, 'start' => \$opt_start, 'end' => \$opt_end) or die("Error in command line arguments\n"); @@ -283,6 +285,8 @@ $cfg = new Config::Simple(CONFIG); die "Cannot read config file\n" unless $cfg; +$opt_nocolor = !(-t STDOUT) unless $opt_forcecolor; + if (!defined $opt_start || !defined $opt_end) { calculate_start_end @ARGV; } -- 2.20.1