prog=${0##*/} # use only the filename, not the pathname while getopts :abo: c do case $c in a) aflag=1;; b) bflag=1;; o) oflag=$OPTARG;; :) print -u2 "$prog: $OPTARG requires a value" exit 2;; \?) print -u2 "$prog: unknown option $OPTARG" print -u2 "Usage: $prog [-a -b -o value] file ..." exit 2;; esac done shift $((OPTIND-1))