# SccsId[] = "%W% (USL function) %G%"
              GO_name="GET_OPTIONS"
              if [ ".${SECONDS}" = "." ]; then # Bourne function already loaded?
                 [ ."`set|egrep '^$GO_name\(\)\{$'`" != . ] && GO_loaded=1
              else # Korn or Bash shell and function already loaded?
                 if [ `expr "\`uname -s\`" : "[Ll][Ii][Nn][Uu][Xx]"` -eq 0 ]; then
                    [ ."`typeset +f|awk '/^'$GO_name'[=\(]?/'`" != . ] && GO_loaded=1
                 else # Linux
                    [ ."`typeset -F|awk '/^'$GO_name'[=\(]?/'`" != . ] && GO_loaded=1
                 fi
              fi
              if [ 0${GO_loaded} -eq 0 ]; then
              #----------------------------------------------------------------------#
              GET_OPTIONS() # Function documentation located at bottom.              #
              #----------------------------------------------------------------------#
              { [ ."${AWK}" = . ] && { { [ -x /usr/bin/nawk ] && AWK=/usr/bin/nawk; } \
                                  ||   { [ -x /bin/gawk     ] && AWK=/bin/gawk    ; } \
                                  ||   { [ -x /usr/bin/awk  ] && AWK=/usr/bin/awk ; }; }

                #------------------------------------------------------------#
                # If the following variables are not set, use these defaults.#
                #------------------------------------------------------------#
                : ${id_num=`/usr/bin/id|/bin/sed 's/^\(uid=\)\([0-9]*\)\(.*\)/\2/'`}
                : ${id_hex=`echo "obase=16;$id_num"|bc`}
                : ${script_name:=`basename $0`}
                : ${name_root:=`echo $script_name|$AWK '{sub(/^\.+/,"");sub(/\..*/,"");print}'`}
                : ${yymmddhhmiss:=`date '+%y''%m%d%H''%M''%S'`}
                : ${Xtimestamp:=`echo "obase=16;$yymmddhhmiss+$$"|bc`}
                : ${tmp:=/var/tmp}

                show_documentation=0 # Global variable
                help_wanted=0        # Global variable
                invalid_opt=0        # Global variable
                GO_root=$tmp/$name_root"_GO_"$id_hex
                GO_err=$GO_root"."$Xtimestamp
                cp /dev/null $GO_err
                while getopts Hh GO_opt 2>> $GO_err
                do
                   case $GO_opt in
                      H ) show_documentation=1;;
                      h ) help_wanted=1;;
                     \? ) echo "$script_name Invalid option:" \
                            "-`sed 's/^.*-- //' $GO_err`"
                          invalid_opt=1;;
                      * ) ;;
                   esac
                done
                shift `expr $OPTIND - 1` # Shift past options to remaining args

                #--------------------------------------------------------------#
                # Must reset this dog if getopts is apt to be called again     #
                OPTIND=1 # (try finding that little gem documented elsewhere). #
                #--------------------------------------------------------------#

                [ ."$GO_root" != . ] && \rm -f $GO_root* > /dev/null 2>&1

                [ $invalid_opt -eq 0 ] && return 0 || return 1
              } # "GO_" prefix identifies this function's local variables.
              fi

              #======================================================================#
              #                       D O C U M E N T A T I O N                      #
              #======================================================================#
              #                                                                      #
              #      Author: Bob Orlando                                             #
              #                                                                      #
              #        Date: December 14, 1996                                       #
              #                                                                      #
              #  Program ID: get_options.sh -Hh                                      #
              #                                                                      #
              #       Usage: GET_OPTIONS                                             #
              #                                                                      #
              #     Purpose: Process basic command line options of -H and -h.        #
              #                                                                      #
              #     Globals: Global variables, $help_wanted, $show_documentation,    #
              #              and $invalid_opt are assigned in this function.         #
              #              "GO_" prefix identifies all local function variables.   #
              #                                                                      #
              # Exit_status: Returns 0 or 1 if invalid option passed.                #
              #                                                                      #
              #       Calls: None.                                                   #
              #                                                                      #
              #       Notes: Options must precede all other command line arguments.  #
              #                                                                      #
              #    Modified: 2004-04-02 Bob Orlando                                  #
              #                 v1.14 * Expand $AWK testing and assignment.          #
              #                                                                      #
              #              2004-03-03 Bob Orlando                                  #
              #                 v1.13 * Change set|egrep|awk to just set|egrep.      #
              #                                                                      #
              #----------------------------------------------------------------------#
            
Artificial Intelligence is no match for natural stupidity.
©Copyright Bob Orlando, 1996-2011
All rights reserved.
http://www.OrlandoKuntao.com
E-mail: Bob@OrlandoKuntao.com
Last update: Jan. 26, 2011
by Bob Orlando