2013-05-02 49 views
-1

代碼如果條件未在bash工作定期

if [ $setup==="y" ] 
    then 
     echo "kurulum:"$setup 
     exit 
     full_dir=$full_dir"/public" 
    else 
    echo "Sub-Public folder is exist? [public,web]" 
     read folder_extend 
     if [ $folder_extend ] 
       then 
       full_dir=$full_dir"/"$folder_extend 
     fi 
fi 

設置PARAM $設置視圖運行SH但仍然狀態firts一部分運行後, 「N」。代碼錯在哪裏?

謝謝。

回答

4

將其更改爲:

if [ "$setup" = "y" ] 
    then 
     echo "kurulum:"$setup 
     exit 
     full_dir=$full_dir"/public" 
    else 
    echo "Sub-Public folder is exist? [public,web]" 
     read folder_extend 
     if [ "$folder_extend" ] 
       then 
       full_dir=$full_dir"/"$folder_extend 
     fi 
fi 

這應該只是一個單一的=,你需要它周圍的空間。你也應該在大多數情況下引用變量,以防它們包含空格。

+0

我使用你的提示,但仍然無法正常工作。結果是:kurulum:n – delirehberi 2013-05-02 11:01:58

+0

@aybarscengaver:你如何填充$ setup? – choroba 2013-05-02 11:03:58

+0

@choroba完整的代碼在這裏http://pastebin.com/7LD94m8i – delirehberi 2013-05-02 11:05:44