Sync usage with man page.
[netbsd-mini2440.git] / share / man / tools / cknames
blob9c685d8c6f183f9cfd0c2c3c984815540044a461
1 #! /bin/sh
3 # $NetBSD$
5 set x $*
6 . ./.param
8 trap "rm -f $TMPDIR/*$$; exit;" 2
10 for sec in $DIRLST
12 /bin/ls $MANDIR/man$sec > $TMPDIR/man${sec}$$
13 done
15 for sec in $DIRLST
17 cd $MANDIR/man$sec
18 dt=`date`
19 echo "$dt\n" > $TMPDIR/not.one.line$sec
20 echo "$dt\n" > $TMPDIR/name.order$sec
21 echo "$dt\n" > $TMPDIR/file.match$sec
22 echo "$dt\n" > $TMPDIR/no.TH$sec
23 echo "$dt\n" > $TMPDIR/no.NAME$sec
24 while read file
26 so=`line < $file | sed "s/ .*$//"`
27 if test "$so" = ".so"
28 then
29 continue
31 grep "^.SH NAME" $file > /dev/null
32 if test $? -eq 1
33 then
34 echo $file >> $TMPDIR/no.NAME$sec
35 continue
37 grep "^.SH SYNOPSIS" $file > /dev/null
38 if test $? -eq 0
39 then
40 lines=`cat $file | sed -n "/\.SH NAME/,/\.SH SYNOP/p" | wc -l | sed "s/ //g"`
41 else
42 lines=`cat $file | sed -n "/\.SH NAME/,/\.SH DESCR/p" | wc -l | sed "s/ //g"`
44 if test $lines -gt 3
45 then
46 echo $file >> $TMPDIR/not.one.line$sec
47 continue
49 th=`grep "^.TH" $file | line`
50 if test -z "$th"
51 then
52 echo $file >> $TMPDIR/no.TH$sec
53 continue
55 set $th
56 name=`echo $2 | tr [A-Z] [a-z]`
57 suf=`echo $3 | tr [A-Z] [a-z]`
58 fname="${name}.$suf"
59 if test $fname != $file
60 then
61 echo $file >> $TMPDIR/file.match$sec
63 ed - $file > $TMPDIR/tmp.$$ <<!
64 /^.SH NAME/+p
67 nname=`cat $TMPDIR/tmp.$$ | sed -e "s/ .*//" -e "s/,.*//"`
68 rm -f $TMPDIR/tmp.$$
69 if test $name != $nname
70 then
71 echo $file >> $TMPDIR/name.order$sec
73 done < $TMPDIR/man${sec}$$
74 done
76 rm -f $TMPDIR/*$$