From 147c2783799a5fec580b7cf58b8fb23b8310513b Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Fri, 9 Dec 2022 21:23:26 +0100 Subject: [PATCH] ignore zero values in report conditions Fix empty stats again, with tests for probable future breakage. --- barcat | 2 +- t/t1600-empty_statistics.out | 2 ++ t/t1601-integer_statistics.out | 2 +- t/t1607-unvalued_statistics.out | 3 +++ 4 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 t/t1600-empty_statistics.out create mode 100644 t/t1607-unvalued_statistics.out 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 -- 2.30.0