我的腳本是在 chroot 中用 systemd 取代 sysvinit,同時使用 debootstrap 建立 debian 映像。
由於這是一個“危險”的操作,apt-get 會問一個愚蠢的問題:“要繼續輸入短語‘是的,按我說的做!’”
我該如何編寫對此的回應腳本?
編輯:我嘗試了所有 -y --yes --force-yes 選項,但它們不起作用。
答案1
奇怪的是,即使是這樣,似乎也會被問到--force-yes
:
apt-get remove -y --force-yes systemd
然而,
echo 'Yes, do as I say!' | apt-get remove systemd
工作得很好。
答案2
apt-get 有一個-y, --yes, --assume-yes
開關:
Automatic yes to prompts; assume "yes" as answer to all prompts and
run non-interactively. If an undesirable situation, such as
changing a held package, trying to install a unauthenticated
package or removing an essential package occurs then apt-get will
abort. Configuration Item: APT::Get::Assume-Yes.
或者,也可以使用開關--force-yes
:
Force yes; this is a dangerous option that will cause apt to
continue without prompting if it is doing something potentially
harmful. It should not be used except in very special situations.
Using force-yes can potentially destroy your system! Configuration
Item: APT::Get::force-yes
http://manpages.ubuntu.com/manpages/utopic/man8/apt-get.8.html