teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0119-kernel-install-add-h-help.patch

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