#!/bin/sh # template.sh: A template for sh scripts # # Usage: template.sh [-ac] [-b OPTARG] FILE... usageMessage="Usage: ${0} [-ac] [-b OPTARG] FILE..." error() { printf '%s error: %s\n' "$0" "$*" >&2 } errorAndUsage() { printf '%s error: %s\n%s\n' "$0" "$*" "$usageMessage" >&2 } # Process options while getopts ':ab:c' opt; do case $opt in 'a' ) echo a ;; 'b' ) echo b "$OPTARG" ;; 'c' ) echo c ;; '?' ) printf '%s\n' "$usageMessage" exit 1 esac done shift $((OPTIND - 1))