changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/lookman

changeset 7243: 34f64dcbbc25
parent: efddda59690a
author: cinap_lenrek@felloff.net
date: Fri, 17 May 2019 18:14:10 +0200
permissions: -rwxr-xr-x
description: 7l: don't hardcode 4k pagesize, use INITRND
1 #!/bin/rc
2 # Usage: lookman key ...
3 # prints out the names of all manual pages containing all the given keywords
4 rfork e
5 index=/sys/lib/man/lookman/index
6 t1=/tmp/look1.$pid
7 t2=/tmp/look2.$pid
8 fn sigexit {
9  rm -f $t1 $t2
10  exit
11 }
12 fn sigint sighup sigterm {
13  rm -f $t1 $t2
14  exit note
15 }
16 
17 *=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_. \012'} # fold case, delete funny chars
18 if(~ $#* 0){
19  echo Usage: lookman key ... >/fd/2
20  exit usage
21 }
22 look $1 $index | sed 's/.* //' | sort -u >$t1
23 shift
24 for(i in $*){
25  look $i $index | sed 's/.* //' | sort -u |
26  awk 'BEGIN {
27  while (getline < "'$t1'" > 0)
28  table[$0] = 1
29  }
30  { if (table[$0]) print }
31  ' > $t2
32  mv $t2 $t1
33 }
34 sort $t1 | sed 's;/sys/man/;;
35  s;(.*)/(.*);man \1 \2 # \2(\1);'
36 exit ''