如果不可用,我该如何忽略代理? 并想编写一个 bash 脚本来创建文件,但该脚本跳过了某些部分并且未包含变量。
$ cat > /etc/apt/detect-http-proxy <<- _EOF_
... all the contents of the file until this line ...
print_msg() {
# \x0d clears the line so [Working] is hidden
[ "$show_proxy_messages" = 1 ] && printf '\x0d%s\n' "$1" >&2
}
for proxy in "${try_proxies[@]}"; do
# if the host machine / proxy is reachable...
if nc -z ${proxy/:/ }; then
proxy=http://$proxy
print_msg "Proxy that will be used: $proxy"
echo "$proxy"
exit
fi
_EOF_
因此,当我执行 cat 时该文件的内容是:
$ cat /etc/apt/detect-http-proxy
print_msg() {
# \x0d clears the line so [Working] is hidden
[ "" = 1 ] && printf '\x0d%s\n' "" >&2
}
for proxy in ""; do
# if the host machine / proxy is reachable...
if nc -z ; then
proxy=http://
print_msg "Proxy that will be used: "
echo ""
exit
fi
我们该如何解决这个问题?2016 年也有一条评论提到Acquire::http::Proxy-Auto-Detect
。我们该如何使用它?
答案1
哈哈,抱歉,找到了答案......只需\
在变量前 输入\$proxy
怎么样Acquire::http::Proxy-Auto-Detect
?