语法错误:“}”意外(预期为“then”)

语法错误:“}”意外(预期为“then”)

我收到一个文件,它帮助我设置环境以在公司网络上工作,但在使它可执行后,我一直遇到有关花括号的错误,它想要 then,我尝试在它说想要它的地方添加 then,但无济于事。这是我试图执行的代码,如果有人能纠正它,那将是天赐之物

echo "Setting up /etc/environment with proxy settings"

if ! grep -q proxy /etc/environment; 
    then
echo "Setting proxy system-wide"
{
    echo "http_proxy=\"http://proxy.cat.com:80/\""
    echo "https_proxy=\"http://proxy.cat.com:80/\""
    echo "ftp_proxy=\"http://proxy.cat.com:80/\""
    echo "socks_proxy=\"http://proxy.cat.com:80/\""
    echo "no_proxy=localhost,127.0.0.0/8,::1,cat.com,*.cat.com,165.26.78.0/23"
} >> /etc/environment
echo "Setting proxy for this session"
export http_proxy=http://proxy.cat.com:80/
export https_proxy=http://proxy.cat.com:80/
export ftp_proxy=http://proxy.cat.com:80/
export socks_proxy=http://proxy.cat.com:80/
else
if grep -q "https://proxy.cat.com" /etc/environment; then
    echo "/etc/environment contains invalid proxy settings, please remove all proxy settings from this file and rerun this script"
    echo "Execute the following command, remove all \"proxy\" lines, save and close: 'sudo gedit /etc/environment'"
    exit 2
fi
echo "/etc/environment already configured with a proxy"
fi

相关内容