免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1074 | 回复: 2
打印 上一主题 下一主题

关于函数返回的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-06-19 09:45 |只看该作者 |倒序浏览
请教诸位大侠,如何在某一功能函数结束后返回主函数继续往下执行,我觉得理论上应该挺简单的,但是我用了“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,很疑惑!请诸位大侠不吝赐教,大恩不言谢!!

论坛徽章:
0
2 [报告]
发表于 2003-06-19 11:38 |只看该作者

关于函数返回的问题

去掉return

论坛徽章:
0
3 [报告]
发表于 2003-06-19 11:51 |只看该作者

关于函数返回的问题

谢谢大侠,鞠躬!!
但还是没有用,我哭.......
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP