From 105fee234213f9aed716540113ca0fbba33e15a3 Mon Sep 17 00:00:00 2001 From: emma Date: Tue, 3 Jan 2023 20:13:36 -0500 Subject: [PATCH] even better --- protonkey | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/protonkey b/protonkey index 8ac2ecb..efd832d 100755 --- a/protonkey +++ b/protonkey @@ -17,21 +17,25 @@ # along with this program. If not, see https://www.gnu.org/licenses/. if ! test -n "$1"; then - printf "Usage: %s [ProtonMail address]\n" "$0" + printf "Usage: %s [ProtonMail address]\n" "$0" 1>&2 exit 64 # syexits(3) EX_USAGE fi -if ! command -v curl > /dev/null; then - printf "%s: Missing dependency: curl(1)\n" "$0" - exit 69 # sysexits(3) EX_UNAVAILABLE -fi +for command in \ + curl \ + gpg +do + if ! command -v "$command" > /dev/null; then + printf "%s: Missing dependency: %s(1)\n" "$0" "$command" 1>&2 + exit 69 # sysexits(3) EX_UNAVAILABLE + fi +done -ADDR="$1" -URL="https://api.protonmail.ch/pks/lookup?op=get&search=$ADDR" +URL="https://api.protonmail.ch/pks/lookup?op=get&search=$1" RESPONSE="$(curl -s "$URL")" if ! printf "%s\n" "$RESPONSE" | gpg --import >/dev/null 2>&1; then - printf "%s\n" "$RESPONSE" + printf "%s\n" "$RESPONSE" 1>&2 exit 76 # sysexits(3) EX_PROTOCOL else exit 0