ขณะติดตั้ง Heroku CLI มีคำสั่งที่ฉันพบ นี่คือคำสั่ง:
curl -L https://cli-assets.heroku.com/apt/release.key | sudo apt-key add -
มันหมายถึงอะไรและมันทำงานอย่างไร
ขณะติดตั้ง Heroku CLI มีคำสั่งที่ฉันพบ นี่คือคำสั่ง:
curl -L https://cli-assets.heroku.com/apt/release.key | sudo apt-key add -
มันหมายถึงอะไรและมันทำงานอย่างไร
คำตอบ:
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...
โอเปอเรเตอร์|คือไพพ์ซึ่งส่งผ่านเอาต์พุตของคำสั่งก่อนที่จะเป็น STDIN ของคำสั่งหลังจากนั้น
apt-keyเป็นเครื่องมือในการเพิ่มคีย์ที่เชื่อถือได้เพื่อเหมาะสำหรับที่เก็บ คุณสามารถดูสิ่งที่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.
ตามที่ระบุไว้-บอกapt key addว่าไฟล์คีย์ควรอ่านจาก STDIN ซึ่งในกรณีนี้คือสิ่งที่ถูกไพพ์จากcurlคำสั่งดังนั้นโดยสรุป:
ดาวน์โหลดไฟล์ใดก็ได้ที่ลิงค์นี้แม้ว่าจะได้ย้ายไปแล้วและเพิ่มเป็นคีย์พื้นที่เก็บข้อมูล APT ที่เชื่อถือได้