读书人

bash的跳转有关问题

发布时间: 2012-02-19 19:43:39 作者: rapoo

bash的跳转问题
请各位帮忙:
请问怎麽样在bash里面实现跳转问题?个人感觉bash里面没有goto的语法.
例如:
if [ -f test.txt ];then
go to shell_end
fi
.
.
其它的处理
.
.
shell_end{
处理
}


[解决办法]
bash没有goto,可以用csh:

#!/bin/csh

goto test
echo "1 "
test:
echo "2 "

不过建议不要用goto,不管是什么语言。你这种情况不妨用函数来包含错误处理代码,在goto的地方调用函数。

读书人网 >UNIXLINUX

热点推荐