Listing 2: kshdoctest.ss

#!/bin/ksh
# Listing 2
# kshdoctest.ss - test the kshdoc function

function my_getopts {
#- version 3.141592, 2002-02-02, Michael Wang <xw73@columbia.edu>.
  typeset PATH= SEP= i
  typeset -u _I
  for i; do
    _I=$i
    eval ${_I%%?(:)=*}= unset ${_I%%?(:)=*}
    case $_I in
      *[!:]=*) eval $(IFS=$SEP; print ${_I%%=*}=\"${_I#*=}\")   ;;
      *:=*)    eval $(IFS=$SEP; print ${_I%%:=*}=\"${i#*:=}\")  ;;
    esac
  done
}

my_getopts "$@"
[[ $HELP = Y ]] && { kshdoc file=$0; exit 0; }

print "This is $0"
print "All script code follows"

## =head1 NAME
##
## B<kshdoctest.ss> - test the I<kshdoc function>
##
## =head1 SYNOPSIS
##
## This is an example script demonstrating how kshdoc functions.
##
## =head1 DESCRIPTION
##
## Using POD directives, highlight a NAME, SYNOPSIS, and DESCRIPTION
## similar to the Unix MAN pages.  All text displayed starts with "## ".

