#!/bin/bash
function keyname() {
	for key in "$@"; do
		while read line; do
			if [ "${line:0:4}" = "pub:" ]; then
				IFS=: eval set -- "\$line"
				keyid="${5:8}"
			fi
			if [ "${line:0:4}" = "uid:" ]; then
				IFS=: eval set -- "\$line"
				printf "gpg-pubkey-%s-%08x\n" "${keyid,,}" "$6"
			fi
		done < <(gpg --with-colons --import-options show-only --import 2>/dev/null < "$key")
	done
}

keyname "$@"
