pci: don't do sanity check for missing pci bus, the check can misfire.
[minix.git] / commands / scripts / makewhatis.sh
blobbf6f16fbb50caf290084a9952523adf9f70b1f20
1 #!/bin/sh
3 # makewhatis 2.2 - make whatis(5) database. Author: Kees J. Bot.
5 # Make the whatis database of a man directory from the manual pages.
7 case $1 in
8 -*) set -$- x x
9 esac
11 case $# in
12 1) ;;
13 *) echo "Usage: $0 <mandir>" >&2
14 exit 1
15 esac
17 cd $1 || exit
20 # First pass, gathering the .SH NAME lines in various forms.
22 # First the man[1-9] directories, the titles are under the .SH NAME
23 # section header.
24 for chap in 1 2 3 4 5 6 7 8 9
26 for page in man$chap/*.$chap
28 if test -f "$page"; then # (Old sh barfs on 'continue')
30 sed -e 's/ / /g
31 s/"NAME"/NAME/g
32 s/^\.Sh/\.SH/g
33 /^\.SH NAME/,/^\.SH /!d
34 /^\.SH /d
35 s/\\f.//g
36 s/\\s[+-].//g
37 s/\\s.//g
38 s/\\//
39 '"s/ - / ($chap) - /" < "$page"
41 done
42 done
44 # The Minix "Book style" documents, look for .CD
45 for page in man1x/*.1x
47 if test -f "$page"; then
49 sed -e 's/ / /g
50 /^\.CD /!d
51 s/^[^"]*"//
52 s/"[^"]*$//
53 s/\\(en/-/g
54 s/\\f.//g
55 s/\\s[+-].//g
56 s/\\s.//g
57 s/\\\*(M2/MINIX/g
58 s/\\//
59 '"s/ - / (1x) - /" < "$page"
61 done
63 # Some people throw extra flat text files into the cat[1-9]
64 # directories. It would be nice if man(1) can find them.
65 trap 'rm -f /tmp/mkw[cmn]$$; exit 1' 1 2 15
66 for chap in 1 2 3 4 5 6 7 8 9
68 ls cat$chap 2>/dev/null >/tmp/mkwc$$
69 ls man$chap 2>/dev/null >/tmp/mkwm$$
70 comm -23 /tmp/mkwc$$ /tmp/mkwm$$ >/tmp/mkwn$$
71 sed -e "/.*\\.$chap\$/!d
72 s/\\.$chap\$/ ($chap) - ???/" < /tmp/mkwn$$
73 done
74 rm -f /tmp/mkw[cmn]$$
75 } | {
76 # Second pass, remove empty lines, leading and trailing spaces,
77 # multiple spaces to one space, remove lines without a dash.
78 sed -e 's/ */ /g
79 s/^ //
80 s/ $//
81 /^$/d
82 /-/!d'
83 } | {
84 # Third pass, sort by section.
85 sort -t'(' +1 -o whatis