xref: /netbsd/bin/ksh/mkman (revision bf9ec67e)
1#!/bin/sh
2
3verbose=no
4
5if [ X"$1" = X-v ] ; then
6    verbose=yes
7    shift
8fi
9if [ $# != 2 ] ; then
10    echo "Usage: $0 [-v] which-shell ksh.Man-file" 1>&2
11    exit 1;
12fi
13shell=$1
14man=$2
15
16case $shell in
17 sh) which=0;;
18 ksh) which=1;;
19 *)
20    echo "$0: bad shell option (must be sh or ksh)" 1>&2
21    exit 1
22    ;;
23esac
24if [ ! -r "$man" ] ; then
25    echo "$0: can't read $man file" 1>&2
26    exit 1;
27fi
28
29
30#
31# Now generate the appropriate man page...
32#
33[ $verbose = yes ] && echo "$0: Generating $which man page (0=sh,1=ksh)..." 1>&2
34
35awk 'BEGIN { ksh = '$which'; pr = 1 }
36    /^\.sh\(/ { pr = ksh - 1; next }
37    /^\.sh\)/ { pr = 1; next }
38    /^\.ksh\(/ { pr = ksh; next }
39    /^\.ksh\)/ { pr = 1; next }
40    { if (pr) print $0 } ' < $man
41
42[ $verbose = yes ] && echo "$0: All done" 1>&2
43
44exit 0
45