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/.
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"
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