if [ $DISTRO = "REDHAT"] || [ $DISTRO = "FEDORA"]; then
if ! rpm -qa | grep -q glibc-static; then
$BIN_ECHO -e " Package [glibc-static] not found. Installing.. "
yum install glibc-static
elif
$BIN_ECHO -e " All required packages installed.. "
fi
elif [ $DISTRO = "DEBIAN"]; then
if ! dpkg-query -l glibc; then
$BIN_ECHO -e " Package [glibc] not found. Installing.. "
apt-get install glibc
elif
$BIN_ECHO -e " All required packages installed.. "
fi
fi
第156行:意外标记“fi”附近的语法错误
如何将两个陈述放在一起?
答案 0 :(得分:4)
每次测试的最终]
之前必须有空格。
例如:
if [ $DISTRO = "REDHAT"] || [ $DISTRO = "FEDORA"]; then
必须重写为:
if [ "$DISTRO" = REDHAT ] || [ "$DISTRO" = FEDORA ]; then
或
if test "$DISTRO" = REDHAT || test "$DISTRO" = FEDORA; then
另请注意,没有理由引用文字字符串,但您应引用变量。
你也可以这样做:
if test "$DISTRO" = REDHAT -o "$DISTRO" = FEDORA; then
或
case "$DISTRO" in
REDHAT|FEDORA) ... ;;
DEBIAN) ... ;;
esac