在安装 Heroku CLI 时,我遇到了一个命令。这是命令:
curl -L https://cli-assets.heroku.com/apt/release.key | sudo apt-key add -
Run Code Online (Sandbox Code Playgroud)
它是什么意思以及它是如何工作的?
Zan*_*nna 45
curl是一个从链接下载东西的实用程序。默认情况下,它写入 STDOUT(即从终端中的链接打印内容)
该-L选项curl的手段:
-L, --location
(HTTP/HTTPS) If the server reports that the requested page has moved to a
different location (indicated with a Location: header and a 3XX response
code), this option will make curl redo the request on the new place...
Run Code Online (Sandbox Code Playgroud)
操作符|是一个管道,它将它前面命令的输出作为后面命令的 STDIN 传递。
apt-key是一个将可信密钥添加到 apt 存储库的实用程序。你可以看到有什么add用man apt-key:
add <filename>
Add a new key to the list of trusted keys. The key is read from the
filename given with the parameter filename or if the filename is -
from standard input.
Run Code Online (Sandbox Code Playgroud)
正如它所提到的,-告诉apt key add密钥文件应该从 STDIN 读取,在这种情况下是从curl命令中通过管道传输的,所以,总而言之:
下载此链接中的任何内容,即使它已移动,并将其添加为受信任的 APT 存储库密钥。