X-Git-Url: http://git.shiar.nl/barcat.git/blobdiff_plain/efddec78ccbd11cda31e97744b83402986338a65..4b923ab2bc237314a2e3558bd16301811ebd1898:/barcat diff --git a/barcat b/barcat index 1818493..2f73fa5 100755 --- a/barcat +++ b/barcat @@ -83,13 +83,14 @@ $opt{'value-length'} = 1 if $opt{unmodified}; my (@lines, @values, @order); +$SIG{ALRM} = sub { + show_lines(); + alarm $opt{interval} if defined $opt{interval} and $opt{interval} > 0; +}; + if (defined $opt{interval}) { $opt{interval} ||= 1; - $SIG{ALRM} = sub { - show_lines(); - alarm $opt{interval}; - }; - alarm $opt{interval}; + alarm $opt{interval} if $opt{interval} > 0; eval { require Tie::Array::Sorted; @@ -99,6 +100,7 @@ if (defined $opt{interval}) { $SIG{INT} = sub { $SIG{INT} = 'DEFAULT'; # reset for subsequent attempts + exit if !$.; 'IGNORE' # continue after assumed eof }; @@ -119,6 +121,8 @@ while (readline) { } } push @lines, $_; + show_lines() if defined $opt{interval} and $opt{interval} < 0 + and $. % $opt{interval} == 0; } $SIG{INT} = 'DEFAULT'; @@ -283,9 +287,10 @@ 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[=] +=item -t, --interval[=(|-)] -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 alarm signal. =item -l, --length=[-][%]