aboutsummaryrefslogtreecommitdiff
path: root/bin/man9
blob: 4eebf7cb5034b8546a86ecc05ccef6abce23dd7d (plain)
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/sh
root=$PLAN9/man

while [ $# -gt 0 ] ; do
    case $1 in
	[0-9]) sec="$sec $1" ;;
	*) break ;;
    esac
    shift
done

if [ "X$sec" = "X" ] ; then
    sec=`ls -d $root/[0-9]* | sed -e 's;/$;;' -e 's;^.*/;;'`
fi

pat='^('`echo $* | sed -e 's; ;|;g'`')' ;
for s in $sec ; do
    if [ -f $root/$s/INDEX ] ; then
	try=`grep -E $pat $root/$s/INDEX | sed -e 's;^[^ ]* ;;'` ;
    fi
    if [ "X$try" != "X" ] ; then
	for f in $try ; do
	    files="$files $root/$s/$f";
	done
	try="";
    fi
    for f in $* ; do
	if [ -f $root/$s/$f ] ; then
	    files="$files $root/$s/$f" ;
	fi
    done
done 

files=`echo $files | tr ' ' '\n' | sort -u`;

if [ "X$files" = "X" ] ; then
    echo "No manual entry for $*";
    exit 1;
fi

exmac=".de EX\n.ift .ft 5\n.nf\n..\n.de EE\n.ft1\n.fi\n.."
( echo -e $exmac ; cat $files ) | nroff -man