summary refs log tree commit diff
path: root/contrib
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-07-23 01:31:37 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-07-23 01:31:37 +0200
commit36b1dbd0d17656c546583cc0da1354bd04a7d66b (patch)
tree7dd3843430e19f1a4634e5c7e0a137426343ca88 /contrib
parenta2ef8e6e61c125b017086b3097b4b7a90321df66 (diff)
downloadmblaze-36b1dbd0d17656c546583cc0da1354bd04a7d66b.tar.gz
mblaze-36b1dbd0d17656c546583cc0da1354bd04a7d66b.tar.xz
mblaze-36b1dbd0d17656c546583cc0da1354bd04a7d66b.zip
add contrib/mthr
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/mthr40
1 files changed, 40 insertions, 0 deletions
diff --git a/contrib/mthr b/contrib/mthr
new file mode 100755
index 0000000..8dd01d6
--- /dev/null
+++ b/contrib/mthr
@@ -0,0 +1,40 @@
+#!/bin/sh
+# mthr [-a|-s|-p] MSGS... - select thread/subthread/parent of messages
+
+mode=1
+case "$1" in
+	-a) mode=1; shift;;
+	-s) mode=2; shift;;
+	-p) mode=3; shift;;
+esac
+
+mseq : | awk -v mode=$mode '
+BEGIN { split("", parents) }
+NR != FNR { exit }
+{
+	match($0, "^ *")
+	ind = RLENGTH
+}
+mode==1 && ind==0 {
+	if (sel)
+		for (i in thread)
+			print thread[i] 
+	split("", thread)
+	sel = 0
+}
+mode==1 { thread[length(thread)+1] = $0 }
+mode==2 && ind <= dep { sel = 0 }
+{
+	for (i in ARGV)
+		if (substr($0, ind+1) == ARGV[i]) {
+			sel = 1
+			dep = ind
+		}
+}
+mode==2 && sel { print }
+mode==3 && sel {
+	print parents[ind-1]
+                 sel = 0
+}
+mode==3 {parents[ind] = $0 }
+' - $(mseq $@)