properly error on options missing an optarg

This commit is contained in:
Dave Reisner 2012-06-18 10:05:40 -04:00
parent 808f744802
commit 120d233639
2 changed files with 6 additions and 0 deletions

View File

@ -70,6 +70,9 @@ while getopts ':Lpr:U' flag; do
# trim trailing slashes
root=${OPTARG%%+(/)}
;;
:)
die '%s: option requires an argument -- '\''%s'\' "${0##*/}" "$OPTARG"
;;
?)
die '%s: invalid option -- '\''%s'\' "${0##*/}" "$OPTARG"
;;

View File

@ -38,6 +38,9 @@ while getopts ':dr:' flag; do
r)
newroot=$OPTARG
;;
:)
die '%s: option requires an argument -- '\''%s'\' "${0##*/}" "$OPTARG"
;;
?)
die '%s: invalid option -- '\''%s'\' "${0##*/}" "$OPTARG"
;;