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

jfh*_*fhr 6 command-line grep stdout

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

sudo apt-key fingerprint 0EBFCD88 | grep "9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88"
Run Code Online (Sandbox Code Playgroud)

这导致了以下输出:

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

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

moo*_*765 5

来自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.
Run Code Online (Sandbox Code Playgroud)

  • 这是什么意思?为什么“如果需要使用 apt-key,则需要额外安装 GNU Privacy Guard 套件(打包在 gnupg 中)”是“强烈建议不要以编程方式使用”的原因?我无法实现这一飞跃。 (3认同)