summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2011-06-09 20:22:31 +0200
committerThomas Bächler <thomas@archlinux.org>2011-06-25 12:25:45 +0200
commit3aedc3b1b6dd4e56c74626a15fa00253f9b07716 (patch)
treefecbfb00a4a71427504b67820761a0d500183564
parent18ba64b65a1d24c7d37e4ddab5c12668e0e097df (diff)
downloadmkinitcpio-3aedc3b1b6dd4e56c74626a15fa00253f9b07716.tar.gz
mkinitcpio-3aedc3b1b6dd4e56c74626a15fa00253f9b07716.tar.xz
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 <d@falconindy.com>
-rwxr-xr-xmkinitcpio7
1 files 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))