An example in Linux programming if--fi

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

 

转载于:https://www.cnblogs.com/kangwang1988/archive/2010/04/23/1718623.html


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部