我正在尝试编写一个grub2 bootloader脚本,但if语句总是评估为true:
if [ -s blabla ] ; then set zzz0="1" ; fi
if [ ! -s blabla ] ; then set zzz1="1" ; fi
set TEST_VAR=foo
if [ "x${TEST_VAR}" = "xfoo" ] ; then set zzz2="1" ; fi
if [ "x${TEST_VAR}" = "xbar" ] ; then set zzz3="1" ; fi
if [ $TEST_VAR = foo ] ; then set zzz4="1" ; fi
if [ $TEST_VAR = bar ] ; then set zzz5="1" ; fi
因此,运行此脚本后,我将所有zzz(zzz0,zzz1,zzz2,zzz3,zzz4,zzz5)变量设置为1.我做错了什么?
谢谢, 约翰尼
答案 0 :(得分:0)
if [ ! "${myvar}" = "" ]; then
(lines here)
else
(lines here)
fi
if [ "${myvar}" = "fred" ]; then
(lines here)
else
(lines here)
fi