commit - d00ad61d517f84ac23bc92005bb041807ac573ce
commit + 0f4372e2c0523c967a83b70b8835bacfb8771f7d
blob - /dev/null
blob + 6431450bc42331a60fb0a3521f8e9df1934930eb (mode 644)
--- /dev/null
+++ bin/diffstat.lp
+# diffstat
+
+Show diff statistics.
+
+ #!/usr/bin/awk -f
+
+maybe not 100% correct, but it's one case where being simple yet
+slightly wrong is way easier than correct. It's not a catastrophe to
+count some extra lines, while parsing the diff (possibly enclosed in a
+mail) is hard.
+
+ /^\+/ { a++ }
+ /^\-/ { m++ }
+
+Don't be a sink! Continue the pipeline so we can further save or apply
+the diff.
+
+ // { print $0 }
+
+At the end, print the stats to standard error to avoid mangling the
+input. Unfortunately, there doesn't seem to be a "built-in" way of
+printing to stderr other than using the pseudo-device.
+
+ END {
+ print "+", a > "/dev/stderr"
+ print "-", m > "/dev/stderr"
+ }
+
+some example usages:
+
+* cvs -q di | diffstat | tee /tmp/diff | less
+* git diff | diffstat > /tmp/diff
+* got di | diffstat | ssh foo 'cd xyz && got patch'
blob - 216dc5ba25485698ac68f01a15b9bfabf3f3d736
blob + e0bf3b64ebd147b76f61e127f9a74ebc645a28cd
--- gen
+++ gen
pair bin/amused-monitor bin/amused-monitor.lp +x
pair bin/browser bin/browser.lp +x
pair bin/clip bin/clip.lp +x
+pair bin/diffstat bin/diffstat.lp +x
pair bin/gamemode bin/gamemode.lp +x
pair bin/gmi2txt bin/gmi2txt.lp +x
pair bin/mquote bin/mquote.lp +x
blob - cdfc78d3dd81b8ece9752e1b7dcf6eb0117e509b
blob + 543b5fda806b67d15f4c52816116a75fe3523944
--- kshrc.lp
+++ kshrc.lp
"${baseurl}/${paste}" | openssl enc -aes-256-cbc \
-base64 -d -K ${key} -iv ${iv}
unset url baseurl vals paste key iv
- }
-
-a little awk oneliner to show the stats of a unified diff
-
- diffstat() {
- awk '
- /^\+/ { a++; next }
- /^\-/ { m++; next }
- END { printf("additions:\t%d\nremoval:\t%d\n", a, m) }
- '
}
find(1) is an invaluable tool and I use it all the time. walk is an