#!/bin/bash function usage { retval="$1" case "$retval" in 0) ;; *) exec 1>&2 ;; esac echo "Usage: $0 --help" exit "$retval" } while [ "$#" -ge 1 ] do case "$1" in -h|--help) usage 0 ;; *) echo "$0: unrecognized option: $1" 1>&2 usage 1 ;; esac shift done echo 'Hello world!'