From: Jameson Graef Rollins Date: Fri, 11 Jul 2008 00:39:55 +0000 (-0400) Subject: Fix argument checking for functions with options. X-Git-Tag: monkeysphere_0.4-1~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=06fc008910dc3f8df8c1a6185f49f22854f8f74b;p=monkeysphere.git Fix argument checking for functions with options. Tweak to prompt for add-certifier. --- diff --git a/src/monkeysphere b/src/monkeysphere index cb6c06c..2227b91 100755 --- a/src/monkeysphere +++ b/src/monkeysphere @@ -90,6 +90,9 @@ gen_subkey(){ done keyID="$1" + if [ -z "$keyID" ] ; then + failure "You must specify the key ID of your primary key." + fi gpgOut=$(gpg --quiet --fixed-list-mode --list-keys --with-colons \ "$keyID" 2> /dev/null) @@ -245,11 +248,7 @@ case $COMMAND in ;; 'gen-subkey'|'g') - keyID="$1" - if [ -z "$keyID" ] ; then - failure "You must specify the key ID of your primary key." - fi - gen_subkey "$keyID" + gen_subkey "$@" ;; 'help'|'h'|'?') diff --git a/src/monkeysphere-server b/src/monkeysphere-server index 9d0d9b3..6534fa1 100755 --- a/src/monkeysphere-server +++ b/src/monkeysphere-server @@ -423,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 @@ -438,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 @@ -472,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" @@ -550,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" ;;