From 3aedc3b1b6dd4e56c74626a15fa00253f9b07716 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Thu, 9 Jun 2011 14:22:31 -0400 Subject: mkinitcpio: only show usage on request Display an actual error message for the user when they enter an incorrect option, or neglect to provide $OPTARG when needed. Signed-off-by: Dave Reisner --- mkinitcpio | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mkinitcpio b/mkinitcpio index c97f93d..3b7346b 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -107,6 +107,7 @@ while getopts ':c:k:sb:g:p:m:nvH:LMhS:t:z:' arg; do s) SAVELIST=1; ;; b) BASEDIR="${OPTARG}" ;; g) GENIMG="${OPTARG}" ;; + h) usage ;; p) PRESET="${OPTARG}" ;; n) COLOR=0 ;; v) QUIET=0 ;; @@ -127,8 +128,10 @@ while getopts ':c:k:sb:g:p:m:nvH:LMhS:t:z:' arg; do M) SHOW_AUTOMODS=1 ;; t) TMPDIR=$OPTARG ;; z) optcompress=$OPTARG ;; - h|?) usage ;; - :) echo "${OPTARG} requires a value..."; usage ;; + :) echo "error: option requires an argument -- '$OPTARG'" >&2 + exit 1 ;; + \?) echo "error: invalid option -- '$OPTARG'" >&2 + exit 1 ;; esac done shift $((OPTIND - 1)) -- cgit v1.2.3-24-g4f1b