任何人都可以告诉我为什么这个bash脚本工作,如果我剪切并粘贴到终端但抛出“server_prep.sh:7:语法错误:”(使用$sudo sh server_prep.sh启动时出现“意外”?
#!/bin/sh #Packages apt-get -y install ssh libsqlite3-dev ruby-full mercurial #Gems required_gems = ( rake rails sqlite3-ruby ) #Set up directories [ ! -d /var/www ] && mkdir /var/www [ ! -d /var/www/apps ] && mkdir /var/www/apps #install gems manually if ! which gem >/dev/null; then wget http://rubyforge.org/frs/download.PHP/60718/rubygems-1.3.5.tgz tar xvfz rubygems-1.3.5.tgz ruby rubygems-1.3.5/setup.rb ln -s /usr/bin/gem1.8 /usr/bin/gem gem update --system #Tidy Up rm -rf rubygems-1.3.5.tgz rubygems-1.3.5 fi #Install required gems for required_gem in "${required_gems[@]}" do if ! gem list | grep $required_gem >/dev/null; then gem install $required_gems fi done
提前致谢!