簡體   English   中英

如果grub2腳本中的語句總是評估為true

[英]if statements in grub2 script always evaluate to true

我正在嘗試編寫一個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.我做錯了什么?

謝謝,約翰尼

if [ ! "${myvar}" = "" ]; then
   (lines here)
else
   (lines here)
fi

if [ "${myvar}" = "fred" ]; then
   (lines here)
else
   (lines here)
fi

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM