0
#!/bin/bash
sudo add-apt-repository
echo -n "Enter ppa here > "
read $response
sudo apt-get update
if [ "W: GPG error: * NO_PUBKEY" = "0" ]; then
echo "Enter the 16 digit key provided at the end of this error."
sudo apt-add adv --keyserver keyserver.ubuntu.com --recv-key
echo -n "Enter key here > "
read text
else
echo "Update succeeded with no errors."
fi
sudo apt-get update
但脚本停止,因为库后,无参数。如何提示用户输入回购?
不能说为什么它停止与无参数,但你意识到你的语句'if [“W:GPG错误:* NO_PUBKEY”=“0”];那么''将总是返回'false'并执行'else'语句,是吗?另外,你的意思是你的脚本('sudo add-apt-repository')中的第一个cmd后停止吗?你的'sudo'设置是否正确?对于这些项目中的任何一个,请改进Q中提供的证据,而不是在评论中进行漫长的讨论。祝你好运。 – shellter