richardphibel / rpms / systemd

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