gpg 2.2.12 has different exit code on failure to import key than 2.2.4

I am trying to connect a bunch of gpg --keyserver attempts with or in order to try several servers, but this is being foiled by the fact that gpg v2.2.12 seems to erroneously return exit code 0 (success) when it fails to import a key:

$ gpg --version
gpg (GnuPG) 2.2.12
...
$ gpg --keyserver hkps://keys.openpgp.org --recv-keys "SOME_KEY"
gpg: key SOME_KEY: new key but contains no user ID - skipped
gpg: Total number processed: 1
gpg: w/o user IDs: 1
$ echo $?
0

It seems incorrect that this would have an exit code of 0, and gpg v2.2.4 seems to agree with me:

$ gpg --version
gpg (GnuPG) 2.2.4
...
$ gpg --keyserver hkps://keys.openpgp.org --recv-keys "SOME_KEY"
gpg: key SOME_KEY: no user ID
gpg: Total number processed: 1
$ echo $?
2

If you're curious why I am referring to 2 gpg's, one is on my main system (Ubuntu), the other is what happens in the container I am using (debian, from the base image of buildpack-deps:buster). Both systems believe these respective versions to be the latest. I would prefer the latter behavior to the former, is there any way to have gpg 2.2.12 behave that way?

Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like