progress after line count with negative --interval
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 11 Sep 2019 14:51:55 +0000 (16:51 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 12 Sep 2019 15:48:11 +0000 (17:48 +0200)
barcat
t/t0002-usage_-h_|wc_-l.out

diff --git a/barcat b/barcat
index b051353ecf2d228ffaeade4e1ab19021cfc569b4..1b780e618d23620456c984ad6e61b36bd2438c78 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -85,12 +85,12 @@ my (@lines, @values, @order);
 
 $SIG{ALRM} = sub {
        show_lines();
-       alarm $opt{interval} if defined $opt{interval};
+       alarm $opt{interval} if defined $opt{interval} and $opt{interval} > 0;
 };
 
 if (defined $opt{interval}) {
        $opt{interval} ||= 1;
-       alarm $opt{interval};
+       alarm $opt{interval} if $opt{interval} > 0;
 
        eval {
                require Tie::Array::Sorted;
@@ -120,6 +120,8 @@ while (readline) {
                }
        }
        push @lines, $_;
+       show_lines() if defined $opt{interval} and $opt{interval} < 0
+               and $. % $opt{interval} == 0;
 }
 
 $SIG{INT} = 'DEFAULT';
@@ -284,9 +286,9 @@ turning long numbers like I<12356789> into I<12.4M>.
 Also changes an exponent I<1.602176634e-19> to I<160.2z>.
 Short integers are aligned but kept without decimal point.
 
-=item -t, --interval[=<seconds>]
+=item -t, --interval[=(<seconds>|-<lines>)]
 
-Interval time to output partial progress.
+Output partial progress every given number of seconds or input lines.
 An update can also be forced by sending a I<SIGALRM> alarm signal.
 
 =item -l, --length=[-]<size>[%]
index 7273c0fa8c522b7eed7762a353d46f7768e9b6f2..6f4247a6255c99f420d1df558d68745592862ff7 100644 (file)
@@ -1 +1 @@
-25
+26