- 论坛徽章:
- 0
|
请教诸位大侠,如何在某一功能函数结束后返回主函数继续往下执行,我觉得理论上应该挺简单的,但是我用了“return”直接返回到主函数开头了,请问这是什么问题?譬如说,这是我的一个功能函数:
attendence()
{
test -f /tmp/log && rm -f /tmp/log
test -p /tmp/pipe1 && rm -f /tmp/pipe1
# create the pipe
mkfifo /tmp/pipe1
while : ; do
dialog --backtitle "www.friends.com" --title "sign up" --inputbox " lease input your name (input q to quit) " 8 40 2> /tmp/pipe1 &
#put the information of sign up box into pipe
read name < /tmp/pipe1 # read the name from pipe
if [ x"$name" = x ]; then
continue
elif [ x"$name" = xq ]; then
break
else
today=`date`
dialog --sleep 3 --backtitle "www.friends.com" --title "sign up" --infobox "[$name] $today" 3 50
echo -e "$name\t$today" >> /tmp/log
fi
done
echo "cat /tmp/log: "
cat /tmp/log
return
}
这是我的主函数:(中间的函数略)
# main program
#
quit="n"
while [ "$quit" != "y" ]
do
greeting
attendence
show_datetime
login
if [$? -eq 0]
then
operation_menu()
result=`cat /tmp/tmpmenu`
case $result in
1) backup;;
2) search;;
3) insert;;
4) modify;;
5) delete;;
*) echo "your choice is not available, please choose again!" operation_menu ;;
esac
else
dialog --backtitle "www.friends.com" --title "Warn!" --yesnobox "Do you want to exit?" 10 40
if [$? -eq 0]; then
quit="y"
else
continue
fi
fi
done
dialog --backtitle "www.friends.com" --title "Message" --msgbox "Bye Bye!\nGood luck to you!" 10 40
exit 0
目前的结果是执行完attendence直接回到了greeting,很疑惑!请诸位大侠不吝赐教,大恩不言谢!! |
|