summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-11-21 13:39:43 -0500
committerJesse Luehrs <doy@tozt.net>2013-12-11 17:14:29 -0500
commitc1756fb01dd0857075659956fe85edbc71877e16 (patch)
tree73686eb490f74ec24ed4cc1b4127bad91351fc4c /bin
parent85dd3c996929c84a2957b547efb23a4ac3180cb2 (diff)
downloadconf-c1756fb01dd0857075659956fe85edbc71877e16.tar.gz
conf-c1756fb01dd0857075659956fe85edbc71877e16.zip
stop splitting on ;
doesn't work too well for things like perl -E'my $foo = 1; say $foo'
Diffstat (limited to 'bin')
-rwxr-xr-xbin/history_stats34
1 files changed, 16 insertions, 18 deletions
diff --git a/bin/history_stats b/bin/history_stats
index d0191ce..b289f97 100755
--- a/bin/history_stats
+++ b/bin/history_stats
@@ -24,25 +24,23 @@ while (<$fh>) {
# strip zsh history timestamps
s/^[^;]*;// if /^:/;
- for my $cmd (split /;/, $_) {
- $cmd =~ s/^\s*(.*?)\s*$/$1/;
- my @words = split /\s+/, $cmd;
- next unless @words;
- shift @words while @words && $words[0] =~ /^[A-Z][A-Z0-9_]*=/;
- next unless @words;
- my $sudo;
- if ($words[0] eq 'sudo') {
- $sudo = 1;
- shift @words;
- }
- if ($subcommand) {
- next unless $words[0] eq $subcommand;
- shift @words;
- shift @words while @words && $words[0] =~ /^-/;
- }
- $cmds{($words[0] || '')}++;
- $sudo_cmds{$words[0]}++ if $sudo;
+ s/^\s*(.*?)\s*$/$1/;
+ my @words = split /\s+/;
+ next unless @words;
+ shift @words while @words && $words[0] =~ /^[A-Z][A-Z0-9_]*=/;
+ next unless @words;
+ my $sudo;
+ if ($words[0] eq 'sudo') {
+ $sudo = 1;
+ shift @words;
}
+ if ($subcommand) {
+ next unless $words[0] eq $subcommand;
+ shift @words;
+ shift @words while @words && $words[0] =~ /^-/;
+ }
+ $cmds{($words[0] || '')}++;
+ $sudo_cmds{$words[0]}++ if $sudo;
}
for my $cmd (sort { $cmds{$b} <=> $cmds{$a} } keys %cmds) {