如何正确使用if else条件来纠正错误

时间:2017-07-21 15:44:02

标签: bash if-statement

#!/bin/bash
$activity1 = zenity  --list  --text " select the option" --radiolist  --column "Select" --column "you are" FALSE "admin" TRUE "customer" ;


if [ $activity1  = "admin"]; then

 ( zenity --password --username );

else [ $activity1 = "customer" ]; then


( zenity --entry );\

--entry-text ""
fi

我收到错误“语法错误:”然后“意外(期待”fi“)” 任何人都可以给我答案吗?

1 个答案:

答案 0 :(得分:1)

不应该有其他条件。

你应该有

if [ $activity1  = "admin"]; then
   ( zenity --password --username );
else # no condition
   zenity --entry );\
   --entry-text ""
fi

或使用elif

if [ $activity1  = "admin"]; then
   ( zenity --password --username );
elif [ $activity1 = "customer" ]; then
   ( zenity --entry );\
   --entry-text ""
fi