Fix argument checking for functions with options.
[monkeysphere.git] / src / monkeysphere-server
index 67466d2feea8ef7af5115fb50715bc6b40c91bcf..6534fa17fb8565506c12a5c41a5f4efb92a949dd 100755 (executable)
@@ -53,9 +53,7 @@ subcommands:
   remove-identity-certifier (r) KEYID   remove a certification key
   list-identity-certifiers (l)          list certification keys
 
-  gpg-authentication-cmd                execute a gpg command to the
-                                        authentication keyring as the
-                                        monkeysphere user
+  gpg-authentication-cmd CMD            gnupg-authentication command
 
   help (h,?)                            this help
 
@@ -425,6 +423,9 @@ add_certifier() {
     done
 
     keyID="$1"
+    if [ -z "$keyID" ] ; then
+       failure "You must specify the key ID of a key to add."
+    fi
     export keyID
 
     # export host ownertrust to authentication keyring
@@ -440,7 +441,8 @@ add_certifier() {
     echo "key found:"
     gpg_authentication "--fingerprint $fingerprint"
 
-    read -p "Are you sure you want to add this key as a certifier of users on this system? (y/N) " OK; OK=${OK:-N}
+    echo "Are you sure you want to add this key as a certifier of"
+    read -p "users on this system? (y/N) " OK; OK=${OK:-N}
     if [ "${OK/y/Y}" != 'Y' ] ; then
        failure "aborting."
     fi
@@ -474,6 +476,9 @@ remove_certifier() {
     local fingerprint
 
     keyID="$1"
+    if [ -z "$keyID" ] ; then
+       failure "You must specify the key ID of a key to remove."
+    fi
 
     # delete the requested key (with prompting)
     gpg_host --delete-key "$keyID"
@@ -552,16 +557,10 @@ case $COMMAND in
        ;;
 
     'add-identity-certifier'|'add-certifier'|'a')
-       if [ -z "$1" ] ; then
-           failure "You must specify a key ID."
-       fi
        add_certifier "$1"
        ;;
 
     'remove-identity-certifier'|'remove-certifier'|'r')
-       if [ -z "$1" ] ; then
-           failure "You must specify a key ID."
-       fi
        remove_certifier "$1"
        ;;