treat zero as non-empty spark value
[barcat.git] / barcat
diff --git a/barcat b/barcat
index 2339bc7e2b8ed8dc8b604ec06e10ed557f9ebcfe..4d3205ff3aec082d3741083e8c438902e45aeb52 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -57,6 +57,7 @@ GetOptions(\%opt,
        'indicators:s',
        'palette=s' => sub {
                $opt{palette} = {
+                       ''     => [],
                        fire   => [qw( 90 31 91 33 93 97 96 )],
                        fire256=> [map {"38;5;$_"} qw(
                                235  52 88 124 160 196
@@ -75,7 +76,11 @@ GetOptions(\%opt,
                                (map { 201 - $_     } 0..4), # -b
                                196,
                        ],
-               }->{$_[1]} // [ split /[^0-9;]/, $_[1] ];
+               }->{$_[1]} // do {
+                       my @vals = split /[^0-9;]/, $_[1]
+                               or die "Empty palette resulting from \"$_[1]\"\n";
+                       \@vals;
+               };
        },
        'stat|s!',
        'signal-stat=s',
@@ -286,7 +291,7 @@ while ($nr <= $limit) {
                $val == $order[-1] ? $opt{palette}->[0] : # min
                $opt{palette}->[ $rel * ($#{$opt{palette}} - 1) + 1 ];
        my $indicator = $opt{indicators} && $opt{indicators}->[
-               !$val || !$#{$opt{indicators}} ? 0 : # blank
+               !length($val) || !$#{$opt{indicators}} ? 0 : # blank
                $#{$opt{indicators}} < 2 ? 1 :
                $val >= $order[0] ? -1 :
                $rel * ($#{$opt{indicators}} - 1e-14) + 1