/bin/cat <<- EndTemplate
#!/bin/ksh
#
# \$Revision: 1.1 \$ \$Date: $(date '+%F %T%:::z') \$
# \$Source: $PWD \$
# \$Host: $(hostname).$DOMAIN \$
# \$UUID: $(uuidgen) \$
#
#<@FILENAME@: do something
#  Full debug output:   DEBUG=1 @FILENAME@
#  Dry-run, show only:  DRYRUN=1 @FILENAME@

export PATH=/usr/local/bin:/bin:/sbin:/usr/bin:\$HOME/bin
set -o nounset
tag=\${0##*/}
umask 022
export PS4='\${tag}-\${LINENO}: '

logmsg () { echo "\$(date '+%F %T.%3N%:::z') \$tag: \$@"; }
die ()    { logmsg "FATAL: \$@"; exit 1; }

# Logging: use "kill \$$" to kill the script with signal 15 even if we're
# in a function, and use the trap to avoid the "terminated" message you
# normally get by using "kill".

trap 'exit 1' 15
logmsg () { echo "\$(date '+%F %T.%3N%:::z') \$tag: \$@" >&2 ; }
die ()    { logmsg "FATAL: \$@"; kill \$$ ; }

# ENVIRONMENT: full debug output?
DEBUG=\${DEBUG:-0}
case "\$DEBUG" in
    1) set -x ;;
    *) ;;
esac

# ENVIRONMENT: is this a dry-run?
DRYRUN=\${DRYRUN:-0}
case "\$DRYRUN" in
    1) dryrun='yes' ;;
    *) dryrun='no' ;;
esac

# If wanted results are empty, print optional line-number and exit.
notempty() {
    line=''
    test -n "\$1" && line=", line \$1"
    in=\$(cat)
    test -n "\$in" || die "empty string\${line}"
    printf "\$in"
}

# Use "new ksh/short @FILENAME@ for better option handling.
case "\$#" in
    0)  die 'need an argument' ;;
    *)  file="\$1" ;;
esac

die 'something wrong here'
logmsg should not get here

# Die on the spot if ITEM would be empty.
ITEM=\$(ls "\$@" 2> /dev/null | notempty \$LINENO)
echo "ITEM=[\$ITEM]"
exit 0
EndTemplate
