572a44
From ced01b28f5e44cc708ae7af681919e4dc83da169 Mon Sep 17 00:00:00 2001
572a44
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
572a44
Date: Sun, 8 Dec 2013 07:46:46 -0500
572a44
Subject: [PATCH] kernel-install: add -h/--help
572a44
572a44
---
572a44
 src/kernel-install/kernel-install | 21 ++++++++++++++-------
572a44
 1 file changed, 14 insertions(+), 7 deletions(-)
572a44
572a44
diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install
572a44
index 9d3e75d..f5ff362 100644
572a44
--- a/src/kernel-install/kernel-install
572a44
+++ b/src/kernel-install/kernel-install
572a44
@@ -21,9 +21,9 @@
572a44
 
572a44
 usage()
572a44
 {
572a44
-    echo "Usage:" >&2
572a44
-    echo "        $0 add <kernel-version> <kernel-image>" >&2
572a44
-    echo "        $0 remove <kernel-version> <kernel-image>" >&2
572a44
+    echo "Usage:"
572a44
+    echo "        $0 add KERNEL-VERSION KERNEL-IMAGE"
572a44
+    echo "        $0 remove KERNEL-VERSION KERNEL-IMAGE"
572a44
 }
572a44
 
572a44
 dropindirs_sort()
572a44
@@ -54,6 +54,13 @@ dropindirs_sort()
572a44
 
572a44
 export LC_COLLATE=C
572a44
 
572a44
+for i in "$@"; do
572a44
+    if [ "$i" == "--help" -o "$i" == "-h" ]; then
572a44
+        usage
572a44
+        exit 0
572a44
+    fi
572a44
+done
572a44
+
572a44
 if [[ "${0##*/}" == 'installkernel' ]]; then
572a44
     COMMAND='add'
572a44
 else
572a44
@@ -75,7 +82,7 @@ if ! [[ $MACHINE_ID ]]; then
572a44
 fi
572a44
 
572a44
 if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
572a44
-    usage
572a44
+    echo "Not enough arguments" >&2
572a44
     exit 1
572a44
 fi
572a44
 
572a44
@@ -90,8 +97,8 @@ readarray -t PLUGINS < <(
572a44
 
572a44
 case $COMMAND in
572a44
     add)
572a44
-        if [[ ! $KERNEL_IMAGE ]]; then
572a44
-            usage
572a44
+        if [[ ! "$KERNEL_IMAGE" ]]; then
572a44
+            echo "Command 'add' requires an argument" >&2
572a44
             exit 1
572a44
         fi
572a44
 
572a44
@@ -121,7 +128,7 @@ case $COMMAND in
572a44
         ;;
572a44
 
572a44
     *)
572a44
-        usage
572a44
+        echo "Unknown command '$COMMAND'" >&2
572a44
         exit 1
572a44
         ;;
572a44
 esac