prepare decremented hidemin value
[barcat.git] / barcat
diff --git a/barcat b/barcat
index 88dc55ce88a646ae1925d84f7bf6a29ffa240f8b..0d843c13e177580776d2b81e4556f38961c0b4e7 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -122,6 +122,7 @@ $opt{'value-length'} = 1 if $opt{unmodified};
 $opt{'signal-stat'} //= exists $SIG{INFO} ? 'INFO' : 'QUIT';
 $opt{markers} //= '=avg >31.73v <68.27v +50v |0';
 $opt{palette} //= $opt{color} && [31, 90, 32];
+$opt{hidemin} = ($opt{hidemin} || 1) - 1;
 $opt{input} = @ARGV && $ARGV[0] =~ m/\A[-0-9]/ ? \@ARGV : undef
        and undef $opt{interval};
 
@@ -191,7 +192,7 @@ sub sival {
 
 sub show_lines {
 
-state $nr = $opt{hidemin} ? $opt{hidemin} - 1 : 0;
+state $nr = $opt{hidemin};
 @lines and @lines > $nr or return;
 @lines or return;
 @lines > $nr or return unless $opt{hidemin};
@@ -294,9 +295,9 @@ say $opt{palette} ? color(0) : '' if $opt{spark};
 
 sub show_stat {
        if ($opt{hidemin} or $opt{hidemax}) {
-               $opt{hidemin} ||= 1;
-               $opt{hidemax} ||= @lines;
-               printf '%s of ', sum(grep {length} @values[$opt{hidemin} - 1 .. $opt{hidemax} - 1]) // 0;
+               printf '%s of ', sum(grep { length }
+                       @values[$opt{hidemin} .. ($opt{hidemax} || @lines) - 1]
+               ) // 0;
        }
        if (@order) {
                my $total = sum @order;