~kris/9p

glenda

ref: c0f1d92cc6ae334cbeaeaaa891282b014723d163 glenda/x/mux/lookman/lookman -rwxr-xr-x 874 bytes
c0f1d92c — Kris Yotam docs: mark as fork of henesy/glenda 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/rc
# Usage: lookman key ...
#	prints out the names of all manual pages containing all the given keywords
rfork e

# Change these to match environment
sed=/usr/local/plan9port/bin/sed
MIRROR=/usr/share/mirror/plan9front
index=$MIRROR/sys/lib/man/lookman/index
LIB=$MIRROR/sys/man

t1=/tmp/look1.$pid
t2=/tmp/look2.$pid
fn sigexit {
	rm -f $t1 $t2
	exit
}
fn sigint sighup sigterm {
	rm -f $t1 $t2
	exit note
}

*=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_. \012'}	# fold case, delete funny chars
if(~ $#* 0){
	echo Usage: lookman key ... >> /dev/stderr
	exit usage
}
look $1 $index | $sed 's/.*	//' | sort -u >$t1
shift
for(i in $*){
	look $i $index | $sed 's/.*	//' | sort -u |
		awk 'BEGIN {
			while (getline < "'$t1'" > 0)
				table[$0] = 1
			}
			{ if (table[$0]) print }
		' > $t2
	mv $t2 $t1
}
sort $t1 | $sed 's;'$LIB'/;;
	s;(.*)/(.*);man \1 \2 # \2(\1);'
exit ''