我收到错误./firefoxinstall.sh:第22行:意外令牌;&'
./firefoxinstall.sh: line 22:
附近的语法错误cat<< EOF> /etc/ld.so.conf.d/firefox.conf'当我运行bash ./firefoxinstall.sh
时。
我写了firefoxinstall.sh,
#!/bin/bash
TARGET=/usr/local
function init()
{
export installroot=$TARGET/src
export workpath=$TARGET
yum –assumeyes install make libjpeg-devel libpng-devel \
libtiff-devel gcc libffi-devel gettext-devel libmpc-devel \
libstdc++46-devel xauth gcc-c++ libtool libX11-devel \
libXext-devel libXinerama-devel libXi-devel libxml2-devel \
libXrender-devel libXrandr-devel libXt dbus-glib \
libXdamage libXcomposite
mkdir -p $workpath
mkdir -p $installroot
cd $installroot
PKG_CONFIG_PATH=“$workpath/lib/pkgconfig”
PATH=$workpath/bin:$PATH
export PKG_CONFIG_PATH PATH
bash -c “
cat << EOF > /etc/ld.so.conf.d/firefox.conf
$workpath/lib
$workpath/firefox
EOF
ldconfig
”
}
function finish()
{
cd $workpath
wget -r –no-parent –reject “index.html*” -nH –cut-dirs=7 http://download.cdn.mozilla.net/pub/mozilla.org/firefox/releases/32.0/linux-x86_64/en-US/firefox-32.0.tar.bz2
tar xvf firefox*
cd bin
ln -s ../firefox/firefox
ldconfig
}
function install()
{
wget $1
FILE=basename $1
if [ ${FILE: -3} == “.xz” ]
then tar xvfJ $FILE
else tar xvf $FILE
fi
SHORT=${FILE:0:4}*
cd $SHORT
./configure –prefix=$workpath
make
make install
ldconfig
cd ..
}
init
install ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.xz
install https://www.dropbox.com/s/m605fa6jgff7kcb/freetype-2.4.9.tar.gz?dl=0
install http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.9.0.tar.gz
install http://ftp.gnome.org/pub/gnome/sources/glib/2.32/glib-2.32.3.tar.xz
install http://cairographics.org/releases/pixman-0.26.0.tar.gz
install http://cairographics.org/releases/cairo-1.12.2.tar.xz
install http://ftp.gnome.org/pub/gnome/sources/pango/1.30/pango-1.30.0.tar.xz
install http://ftp.gnome.org/pub/gnome/sources/atk/2.4/atk-2.4.0.tar.xz
install http://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/2.26/gdk-pixbuf-2.26.1.tar.xz
install http://ftp.gnome.org/pub/gnome/sources/gtk+/2.24/gtk+-2.24.10.tar.xz
finish
adds the /usr/local/bin to your path by updating your .bashrc file.
cat << EOF >> ~/.bashrc
PATH=/usr/local/bin:\$PATH
export PATH
EOF
我真的无法理解为什么会发生这样的语法错误。我不认为语法错误就在第22行附近。我怎么能解决这个问题?我的代码有什么问题?
答案 0 :(得分:3)
也许您从某个网页复制了这段代码?
要解决该错误,只需将所有<
替换为<
,将所有>
替换为>
。
我在第22行(cat << EOF > /etc/ld.so.conf.d/firefox.conf
)上看到了这样的序列,并在末尾(cat << EOF >> ~/.bashrc
)旁边看到了一行。
您还应该使用纯双引号(“ ”
)替换印刷引号("
)
答案 1 :(得分:0)