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