我的問題是,我不明白爲什麼當我運行腳本,如果我寫「是」或「否」,它總是說我退出腳本。我知道它不承認$reply
和「是」相等,但爲什麼? (我是bash編程的新手)。謝謝!如果和別的,不同的變量和相同的結果
#!/bin/bash
clear
echo 'This script will install: Firefox 17.0.1 (language: enGB or itIT or enUS) and flash 11 in Firefox17.0.1, continue?'
read reply
if (("$reply" = "yes")); then
pkill firefox
rm -rf /tmp/fox
mkdir /tmp/fox
cd /tmp/fox
rm -rf /opt/firefox/*
rm -rf /usr/lib/mozilla/plugins/*
rm -f /usr/share/icons/mozicon128.png
mkdir /usr/lib/mozilla/plugins
mkdir /opt/firefox
echo "Enter your language (exmp: it en us)"
read reply1
if (("$reply1" = "it")); then
wget ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/latest/linux-x86_64/it-IT/firefox-17.0.1.tar.bz2
elif (("$reply1" = "en")); then
wget ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/latest/linux-x86_64/en-GB/firefox-17.0.1.tar.bz2
else
wget ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/latest/linux-x86_64/en-US/firefox-17.0.1.tar.bz2
fi
wget http://fpdownload.macromedia.com/get/flashplayer/pdc/11.2.202.258/install_flash_player_11_linux.x86_64.tar.gz
wget http://upload.wikimedia.org/wikipedia/commons/7/76/Mozilla_Nightly_icon_2011.png
tar -xvf firefox-17.0.1.tar.bz2
tar -xvf install_flash_player_11_linux.x86_64.tar.gz
cp -R firefox/* /opt/firefox
cp libflashplayer.so /usr/lib/mozilla/plugins/
rm -f /opt/firefox/icons/mozicon128.png
cp -f Mozilla_Nightly_icon_2011.png /opt/firefox/icons/mozicon128.png
echo "Reboot the system to show the new icon?"
read response
if (("$response" = "yes")); then
reboot
else
echo 'Installation Complete'
fi
else
echo "I'm quitting the script..."
exit
fi
如果你混淆不同類型的括號:http://stackoverflow.com/questions/2188199/bash-double-or-single-bracket-parentheses-curly-braces – Ixanezis
順便說一句,強制地'/ usr'中的東西很少是一個好主意。爲你的pkatform(RPM?Deb?Gentoo?你不是這麼說)創建一個軟件包並以正常的方式安裝它。 – tripleee
您需要'[[]]'不要(())' - 對於@tripleee也需要+1 - 爲您的系統處理卸載而創建一個package/formula/recipe。 – ocodo