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.
13 *) echo "Usage: $0 <mandir>" >&2
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
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')
33 /^\.SH NAME/,/^\.SH /!d
39 '"s/ - / ($chap) - /" < "$page"
44 # The Minix "Book style" documents, look for .CD
45 for page
in man1x
/*.1x
47 if test -f "$page"; then
59 '"s/ - / (1x) - /" < "$page"
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$$
76 # Second pass, remove empty lines, leading and trailing spaces,
77 # multiple spaces to one space, remove lines without a dash.
84 # Third pass, sort by section.
85 sort -t'(' +1 -o whatis