From: Mischa POSLAWSKY Date: Fri, 9 Dec 2022 20:23:26 +0000 (+0100) Subject: ignore zero values in report conditions X-Git-Tag: v1.10~5 X-Git-Url: http://git.shiar.nl/barcat.git/commitdiff_plain/147c2783799a5fec580b7cf58b8fb23b8310513b ignore zero values in report conditions Fix empty stats again, with tests for probable future breakage. --- diff --git a/barcat b/barcat index 655f386..cb3282e 100755 --- a/barcat +++ b/barcat @@ -448,7 +448,7 @@ sub varfmt { defined && do { $_ = $opt{'value-format'}->($_) if $format; if ($cmd and $op eq ':') { - $_ = varfmt($cmd, $vars); + $_ = !!$_ && varfmt($cmd, $vars); } elsif ($cmd) { eval $cmd; diff --git a/t/t1600-empty_statistics.out b/t/t1600-empty_statistics.out new file mode 100644 index 0000000..5c6a768 --- /dev/null +++ b/t/t1600-empty_statistics.out @@ -0,0 +1,2 @@ +barcat -s input/empty_input.txt +0 values diff --git a/t/t1601-integer_statistics.out b/t/t1601-integer_statistics.out index b91b3e8..a80eec5 100644 --- a/t/t1601-integer_statistics.out +++ b/t/t1601-integer_statistics.out @@ -1,2 +1,2 @@ -barcat -sL0 input/seq3.txt +barcat -s input/seq3.txt | tail -n1 6 total in 3 values (1 min, 2.00 avg, 3 max) diff --git a/t/t1607-unvalued_statistics.out b/t/t1607-unvalued_statistics.out new file mode 100644 index 0000000..7b5a121 --- /dev/null +++ b/t/t1607-unvalued_statistics.out @@ -0,0 +1,3 @@ +echo | barcat -s + +0 values over 1 lines