Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

Why should apt-key output not be parsed?

Writer Andrew Henderson

To validate that the docker gpg key is installed, I ran:

sudo apt-key fingerprint 0EBFCD88 | grep "9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88"

Which resulted in the following output:

Warning: apt-key output should not be parsed (stdout is not a terminal) 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88

I found this Stack Overflow question on how to circumvent the warning, but I couldn't find any sources on why it appears in the first place? What's the reason you shouldn't parse apt-key output?

1 Answer

From man apt-key:

DESCRIPTION apt-key is used to manage the list of keys used by apt to authenticate packages. Packages which have been authenticated using these keys will be considered trusted. Note that if usage of apt-key is desired the additional installation of the GNU Privacy Guard suite (packaged in gnupg) is required. For this reason alone the programmatic usage (especially in package maintainer scripts!) is strongly discouraged. Further more the output format of all commands is undefined and can and does change whenever the underlying commands change. apt-key will try to detect such usage and generates warnings on stderr in these cases.
1

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