为什么不应解析 apt-key 输出?

为什么不应解析 apt-key 输出?

为了验证 docker gpg 密钥是否已安装,我运行了:

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

输出结果如下:

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

我发现这个 Stack Overflow 问题关于如何规避警告,但我找不到任何关于它为什么会出现的资料?你不应该解析apt-key输出的原因是什么?

答案1

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.

相关内容