summaryrefslogtreecommitdiff
path: root/mkman
blob: 19592811ab152fd9714bd528d47b7ee59a9a2232 (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
44
45
46
#!/bin/sh

: ${AWK:=awk}

verbose=no

if [ X"$1" = X-v ] ; then
    verbose=yes
    shift
fi
if [ $# != 2 ] ; then
    echo "usage: $0 [-v] which-shell ksh.Man-file" 1>&2
    exit 1;
fi
shell=$1
man=$2

case $shell in
 sh) which=0;;
 ksh) which=1;;
 *)
    echo "$0: bad shell option (must be sh or ksh)" 1>&2
    exit 1
    ;;
esac
if [ ! -r "$man" ] ; then
    echo "$0: can't read $man file" 1>&2
    exit 1;
fi


#
# Now generate the appropriate man page...
#
[ $verbose = yes ] && echo "$0: Generating $which man page (0=sh,1=ksh)..." 1>&2

${AWK} 'BEGIN { ksh = '$which'; pr = 1 }
    /^\.sh\(/ { pr = ksh - 1; next }
    /^\.sh\)/ { pr = 1; next }
    /^\.ksh\(/ { pr = ksh; next }
    /^\.ksh\)/ { pr = 1; next }
    { if (pr) print $0 } ' < $man

[ $verbose = yes ] && echo "$0: All done" 1>&2

exit 0