git.shiar.nl
/
barcat.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
document statistics signaling
[barcat.git]
/
barcat
diff --git
a/barcat
b/barcat
index 0558da6bd0d569d42ef75328d43fb59a17b377b2..3eb004e56495a5dbf9afda46ed481db43e493199 100755
(executable)
--- a/
barcat
+++ b/
barcat
@@
-151,7
+151,7
@@
$opt{report} //= join('',
'${sum+; color(1); $_ .= " total in "}',
'${count#} values',
'${lines#; $_ = $_ != @order && " over $_ lines"}',
'${sum+; color(1); $_ .= " total in "}',
'${count#} values',
'${lines#; $_ = $_ != @order && " over $_ lines"}',
- sprintf('
(%s)
', join ', ',
+ sprintf('
${count: (%s)}
', join ', ',
'${min; color(31)} min',
'${avg; $opt{reformat} or $_ = sprintf "%0.2f", $_; color(36)} avg',
'${max; color(32)} max',
'${min; color(31)} min',
'${avg; $opt{reformat} or $_ = sprintf "%0.2f", $_; color(36)} avg',
'${max; color(32)} max',
@@
-396,21
+396,23
@@
sub show_stat {
max => $order[0],
);
$vars{avg} = $vars{sum} / @order;
max => $order[0],
);
$vars{avg} = $vars{sum} / @order;
- print varfmt($opt{report}, \%vars);
}
}
- say
''
;
+ say
varfmt($opt{report}, \%vars)
;
return 1;
}
sub varfmt {
my ($fmt, $vars) = @_;
$fmt =~ s[\$\{ \h*+ ((?: [^{}]++ | \{(?1)\} )+) \}]{
return 1;
}
sub varfmt {
my ($fmt, $vars) = @_;
$fmt =~ s[\$\{ \h*+ ((?: [^{}]++ | \{(?1)\} )+) \}]{
- my ($name, $
cmd) = split /\s*;
/, $1, 2;
+ my ($name, $
op, $cmd) = split /\s*([;:])
/, $1, 2;
my $format = $name =~ s/\+// || $name !~ s/\#// && $opt{reformat};
local $_ = $vars->{$name};
defined && do {
$_ = $opt{'value-format'}->($_) if $format;
my $format = $name =~ s/\+// || $name !~ s/\#// && $opt{reformat};
local $_ = $vars->{$name};
defined && do {
$_ = $opt{'value-format'}->($_) if $format;
- if ($cmd) {
+ if ($cmd and $op eq ':') {
+ $_ = varfmt($cmd, $vars);
+ }
+ elsif ($cmd) {
eval $cmd;
warn "Error in \$$name report: $@" if $@;
}
eval $cmd;
warn "Error in \$$name report: $@" if $@;
}
@@
-646,6
+648,10
@@
Unspecified, block fill glyphs U+2581-2588 will be used.
Total statistics after all data.
Total statistics after all data.
+While processing (possibly a neverending pipe),
+intermediate results are also shown on signal I<SIGINFO> if available (control+t on BSDs)
+or I<SIGQUIT> otherwise (ctrl+\ on linux).
+
=item -u, --unmodified
Do not reformat values, keeping leading whitespace.
=item -u, --unmodified
Do not reformat values, keeping leading whitespace.