mirror of
https://github.com/leahneukirchen/mblaze
synced 2024-11-11 13:10:32 +00:00
41 lines
683 B
Plaintext
41 lines
683 B
Plaintext
|
#!/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 $@)
|