]> xenbits.xensource.com Git - libvirt.git/commitdiff
libvirt-guests: detect invalid arguments
authorEric Blake <eblake@redhat.com>
Tue, 27 Jul 2010 18:05:27 +0000 (12:05 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 28 Jul 2010 12:46:29 +0000 (06:46 -0600)
Reject extra arguments.
Return the correct status for unknown arguments, as mandated by
https://fedoraproject.org/wiki/Packaging/SysVInitScript
Add --help, as a permitted extension.

* daemon/libvirt-guests.init.in (usage): New function.  Use it in
more places, and return correct value.

daemon/libvirt-guests.init.in

index d2ec96a247ac692696f5e8d98ab1f969fc3b2cf6..3a5b205364b4285196d9bf5121ddd0412753b09c 100644 (file)
@@ -282,8 +282,21 @@ gueststatus() {
     done
 }
 
+# usage [val]
+# Display usage string, then exit with VAL (defaults to 2).
+usage() {
+    echo $"Usage: $0 {start|stop|restart|force-reload|gueststatus|shutdown}"
+    exit ${1-2}
+}
+
 # See how we were called.
+if test $# != 1; then
+    usage
+fi
 case "$1" in
+    --help)
+        usage 0
+        ;;
     start|stop|gueststatus)
         $1
         ;;
@@ -304,8 +317,7 @@ case "$1" in
         stop
         ;;
     *)
-        echo $"Usage: $0 {start|stop|restart|force-reload|gueststatus|shutdown}"
-        exit 3
+        usage
         ;;
 esac
 exit $RETVAL