An example in Linux programming

Original code:

#!/bin/sh
dialog --title "Confirm" --yesno "Are you willing to take part?" 9 18
if [ $? !=0 ];then
dialog --infobox "Thank you anyway" 5 20

sleep 2
dialog --clear
exit 0
fi

The shell always warns there is a syntax error there , with no idea about what's happening, I begin to from the bottom to the top, i.e, from the element test to the system one. Finally, I found where exactly the problem is ,it seems that a null line or simple echo command instead of the dialog command is needed, so the script goes ok when modified as below:

 

#!/bin/sh
dialog --title "Confirm" --yesno "Are you willing to take part?" 9 18

if [ $?!=0 ];then
 #echo "wangkang"
dialog --infobox "Thank you anyway" 5 20
sleep 2
dialog --clear
exit 0
fi

 

你可能感兴趣的:(programming)