#! /bin/sh
#
# NAME
#   name - one line description
#
# SYNOPSIS
#   name [optional args in square brackets]
#
# DESCRIPTION
#
# OPTIONS
#   --debug
#     Turn on debugging messages.
#
#   --help
#     Display the usage of this command.
#
#   --version
#     Display program version.
#
# RETURN VALUE
#
# EXAMPLES
#
# ENVIRONMENT
#
# FILES
#
# SEE ALSO
#
# VERSION
#   TODO
#
# AUTHOR
#   Bill Wohler &lt;wohler&#64newt.com>
#
#   Copyright (C) 2000, 2021  Newt Software
#   
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License
#   as published by the Free Software Foundation; either version 2
#   of the License, or (at your option) any later version.
#   
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, you can find it at
#   http://www.gnu.org/copyleft/gpl.html or write to the Free Software
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

# Initializations.

# Constants.
cmd=`basename $0`                       # name by which command called

# Program version: start with CVS version, strip dollar signs, CVS keyword
# and whitespace.
ver=TODO

# Variables (may be overridden by arguments).
debug=0                                 # verbose mode

exitstatus=0                            # upon error, set to non-zero and exit
interrupt=0                             # upon interrupt, set to 1

# Functions.

# Display usage information and exit.
usage() {
    cat <<EOF
Usage: $cmd [options]
--debug                 print actions that program takes
--help                  display this message
--version               display program version
EOF
    bye 1;
}

# Exit gracefully.
# Usage: bye [(status [message]]
bye() {
    if [ $# -gt 0 ]; then
        exitstatus=$1
        shift
    fi
    if [ $# -gt 0 ]; then
        echo "$*"
    elif [ $interrupt -eq 1 ]; then
        echo ""
    fi
    exit $exitstatus
}

# Handle an interrupt.
intr() {
    echo ""
    interrupt=1
    bye 1
}

# Display version information and exit.
show_version() {
    cat <<EOF
$cmd version $ver
Copyright (C) Bill Wohler &lt;wohler&#64newt.com>

$cmd comes with ABSOLUTELY NO WARRANTY.

This is free software, and you are welcome
to redistribute it under certain conditions.

See http://www.gnu.org/copyleft/gpl.html for details.
EOF
    exit 0;
}

# Parse command line.
while [ $# != 0 ]; do
    case "$1" in
    --d*)       debug=1;;
    --h*)       usage;;
    --v*)       show_version;;
    -*)         usage;;
    *)          break;;
    esac
    shift
done

trap intr 2

# ADD CODE HERE

bye

