I want to dearmor
a gpg
key only if that gpg
key is enarmored
.
Here is the enarmor and dearmor:
https://manpages.ubuntu.com/manpages/jammy/man1/gpg.1.html
--enarmor
--dearmor
Pack or unpack an arbitrary input into/from an OpenPGP ASCII armor. This is a
GnuPG extension to OpenPGP and in general not very useful.
Here is the gpg key:
/path/to/gpg/key.gpg
Here is the bash function:
check_and_dearmor() {
if [[ "$(is_enarmored "/path/to/gpg/key.gpg")" == "true" ]]
then
echo "gpg is enarmored, dearmor it"
gpg --dearmor "/path/to/gpg/key.gpg"
else
echo "gpg is already dearmored, ignore the gpg --dearmor command"
fi
}
How to implement the “is_enarmored
” in bash
? Or what command can be used to check if the gpg
is enarmored
or not?