#!/bin/sh usage() { printf "Usage: %s [-h]\n" "$0" } help() { cat << EOH SYNOPSIS $0 [-h] DESCRIPTION $0 does things! OPTIONS -h Show this help EOH } on_interrupt() { print "Process aborted!\n" exit 130 } main() { while getopts "hf:" option; do case "${option}" in h) help; exit 0;; f) FOO="$OPTARG";; *) usage; exit 1;; esac done FOO="${FOO:-defaultValue}" exit 0 } trap on_interrupt INT main "$@"