- 论坛徽章:
- 0
|
原帖由 wangduo112 于 2009-3-2 15:24 发表 ![]()
那看到很多人退出都写exit 1 这样的命令退出啊。加上一个1 是别有意义,还是画蛇添足啊?
exit n ,是退出程序(脚本)的
n是返回给shell的,1~255通常用于程序出错时的返回值,0则表示程序运行正常的返回值,这样方便调试时查找原因
return [n]
Causes a function to exit with the return value
specified by n. If n is omitted, the return status
is that of the last command executed in the func-
tion body. If used outside a function, but during
execution of a script by the . (source) command,
it causes the shell to stop executing that script
and return either n or the exit status of the last
command executed within the script as the exit sta-
tus of the script. If used outside a function and
not during execution of a script by ., the return
status is false. Any command associated with the
RETURN trap is executed before execution resumes
after the function or script.
return是函数返回给脚本的
[ 本帖最后由 haimming 于 2009-3-2 16:26 编辑 ] |
|