Archived
1
0

even better

This commit is contained in:
Emma Tebibyte 2023-01-03 20:13:36 -05:00
parent 914d1e64a2
commit 105fee2342

View File

@ -17,21 +17,25 @@
# along with this program. If not, see https://www.gnu.org/licenses/. # along with this program. If not, see https://www.gnu.org/licenses/.
if ! test -n "$1"; then 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 exit 64 # syexits(3) EX_USAGE
fi fi
if ! command -v curl > /dev/null; then for command in \
printf "%s: Missing dependency: curl(1)\n" "$0" curl \
exit 69 # sysexits(3) EX_UNAVAILABLE gpg
fi 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=$1"
URL="https://api.protonmail.ch/pks/lookup?op=get&search=$ADDR"
RESPONSE="$(curl -s "$URL")" RESPONSE="$(curl -s "$URL")"
if ! printf "%s\n" "$RESPONSE" | gpg --import >/dev/null 2>&1; then 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 exit 76 # sysexits(3) EX_PROTOCOL
else else
exit 0 exit 0