From a2704823c7770bc8df9377116877fcca78c3ea12 Mon Sep 17 00:00:00 2001 From: mike castleman Date: Sat, 11 Jul 2009 16:19:31 -0400 Subject: more replacement of read -p with printf; read (re #446) --- src/share/common | 3 ++- src/share/ma/add_certifier | 4 ++-- src/share/ma/remove_certifier | 3 ++- src/share/mh/add_hostname | 5 ++--- src/share/mh/add_revoker | 4 ++-- src/share/mh/publish_key | 3 ++- src/share/mh/revoke_hostname | 16 ++++++++-------- src/share/mh/revoke_key | 6 ++++-- src/share/mh/set_expire | 3 ++- 9 files changed, 26 insertions(+), 21 deletions(-) (limited to 'src/share') diff --git a/src/share/common b/src/share/common index bd887d3..c88857e 100644 --- a/src/share/common +++ b/src/share/common @@ -291,7 +291,8 @@ Please specify how long the key should be valid. y = key expires in n years EOF while [ -z "$keyExpire" ] ; do - read -p "Key is valid for? (0) " keyExpire + printf "Key is valid for? (0) " >&2 + read keyExpire if ! test_gpg_expire ${keyExpire:=0} ; then echo "invalid value" >&2 unset keyExpire diff --git a/src/share/ma/add_certifier b/src/share/ma/add_certifier index 402da08..1601997 100644 --- a/src/share/ma/add_certifier +++ b/src/share/ma/add_certifier @@ -136,8 +136,8 @@ EOF gpg_sphere "--fingerprint 0x${fingerprint}!" if [ "$PROMPT" = "true" ] ; then - echo "Are you sure you want to add the above key as a certifier" - read -p "of users on this system? (Y/n) " OK; OK=${OK:-Y} + printf "Are you sure you want to add the above key as a certifier\nof users on this system? (Y/n) " >&2 + read OK; OK=${OK:-Y} if [ "${OK/y/Y}" != 'Y' ] ; then failure "Identity certifier not added." fi diff --git a/src/share/ma/remove_certifier b/src/share/ma/remove_certifier index 6c90358..79f1cda 100644 --- a/src/share/ma/remove_certifier +++ b/src/share/ma/remove_certifier @@ -27,7 +27,8 @@ fi gpg_core --list-key --fingerprint "0x${keyID}!" || failure if [ "$PROMPT" = "true" ] ; then - read -p "Really remove the above listed identity certifier? (Y/n) " OK; OK=${OK:-Y} + printf "Really remove the above listed identity certifier? (Y/n) " >&2 + read OK; OK=${OK:-Y} if [ "${OK/y/Y}" != 'Y' ] ; then failure "Identity certifier not removed." fi diff --git a/src/share/mh/add_hostname b/src/share/mh/add_hostname index 36f174d..9465d96 100644 --- a/src/share/mh/add_hostname +++ b/src/share/mh/add_hostname @@ -32,9 +32,8 @@ find_host_userid > /dev/null && \ failure "Host userID '$userID' already exists." if [ "$PROMPT" = "true" ] ; then - read -p "The following user ID will be added to the host key: - $userID -Are you sure you would like to add this user ID? (Y/n) " OK; OK=${OK:=Y} + printf "The following user ID will be added to the host key:\n %s\nAre you sure you would like to add this user ID? (Y/n) " "$userID" >&2 + read OK; OK=${OK:=Y} if [ "${OK/y/Y}" != 'Y' ] ; then failure "User ID not added." fi diff --git a/src/share/mh/add_revoker b/src/share/mh/add_revoker index 077b0d0..e58995b 100644 --- a/src/share/mh/add_revoker +++ b/src/share/mh/add_revoker @@ -90,8 +90,8 @@ EOF su_monkeysphere_user "GNUPGHOME=$tmpDir gpg --fingerprint 0x${fingerprint}!" if [ "$PROMPT" = "true" ] ; then - read -p "Are you sure you want to add the above key as a revoker -of the host key? (Y/n) " OK; OK=${OK:-Y} + printf "Are you sure you want to add the above key as a revoker\nof the host key? (Y/n) " >&2 + read OK; OK=${OK:-Y} if [ "${OK/y/Y}" != 'Y' ] ; then failure "revoker not added." fi diff --git a/src/share/mh/publish_key b/src/share/mh/publish_key index b0ffd93..f6e1c0f 100644 --- a/src/share/mh/publish_key +++ b/src/share/mh/publish_key @@ -18,7 +18,8 @@ publish_key() { local GNUPGHOME if [ "$PROMPT" = "true" ] ; then - read -p "Really publish host key to $KEYSERVER? (Y/n) " OK; OK=${OK:=Y} + printf "Really publish host key to $KEYSERVER? (Y/n) " >&2 + read OK; OK=${OK:=Y} if [ "${OK/y/Y}" != 'Y' ] ; then failure "key not published." fi diff --git a/src/share/mh/revoke_hostname b/src/share/mh/revoke_hostname index 5dc327f..44ba312 100644 --- a/src/share/mh/revoke_hostname +++ b/src/share/mh/revoke_hostname @@ -27,11 +27,12 @@ if [ -z "$1" ] ; then failure "You must specify a hostname to revoke." fi -echo "WARNING: There is a known bug in this function." -echo "This function has been known to occasionally revoke the wrong hostname." -echo "Please see the following bug report for more information:" -echo "https://labs.riseup.net/code/issues/show/422" -read -p "Are you sure you would like to proceed? (y/N) " OK; OK=${OK:=N} +echo "WARNING: There is a known bug in this function. +This function has been known to occasionally revoke the wrong hostname. +Please see the following bug report for more information: +https://labs.riseup.net/code/issues/show/422" >&2 +printf "Are you sure you would like to proceed? (y/N) " >&2 +read OK; OK=${OK:=N} if [ ${OK/y/Y} != 'Y' ] ; then failure "aborting." fi @@ -43,9 +44,8 @@ uidIndex=$(find_host_userid) || \ failure "No non-revoked user ID found matching '$userID'." if [ "$PROMPT" = "true" ] ; then - read -p "The following host key user ID will be revoked: - $userID -Are you sure you would like to revoke this user ID? (Y/n) " OK; OK=${OK:=Y} + printf "The following host key user ID will be revoked:\n %s\nAre you sure you would like to revoke this user ID? (Y/n) " "$userID" >&2 + read OK; OK=${OK:=Y} if [ "${OK/y/Y}" != 'Y' ] ; then failure "User ID not revoked." fi diff --git a/src/share/mh/revoke_key b/src/share/mh/revoke_key index ad68d5f..5460e51 100644 --- a/src/share/mh/revoke_key +++ b/src/share/mh/revoke_key @@ -33,7 +33,8 @@ Publishing this certificate will IMMEDIATELY and PERMANENTLY revoke your host key! EOF - read -p "Publish the certificate after generation? (y/n/Q) " publish + printf "Publish the certificate after generation? (y/n/Q) " >&2 + read publish if ! [ "${publish/y/Y}" = 'Y' -o "${publish/n/N}" = 'N' ] ; then failure "aborting at user request" @@ -87,7 +88,8 @@ y if [ "${publish/y/Y}" = 'Y' ] ; then printf "\n" >&2 - read -p "Really publish this cert to $KEYSERVER ? (Y/n) " really + printf "Really publish this cert to $KEYSERVER ? (Y/n) " >&2 + read really if [ "${really/n/N}" = 'N' ] ; then printf "Not publishing.\n" >&2 else diff --git a/src/share/mh/set_expire b/src/share/mh/set_expire index a6bf1f1..9889e76 100644 --- a/src/share/mh/set_expire +++ b/src/share/mh/set_expire @@ -22,7 +22,8 @@ local extendTo extendTo=$(get_gpg_expiration "$1") if [ "$PROMPT" = "true" ] ; then - read -p "Are you sure you want to change the expiration on the host key to '$extendTo'? (Y/n) " OK; OK=${OK:-Y} + printf "Are you sure you want to change the expiration on the host key to '%s'? (Y/n) " "$extendTo" >&2 + read OK; OK=${OK:-Y} if [ "${OK/y/Y}" != 'Y' ] ; then failure "expiration not set." fi -- cgit v1.2.3