[英]Why do many init.d scripts end in “exit $?”?
I've seen a lot of strange quirks in CentOS 6.5's init.d scripts, but one pattern I've seen at the end of most of these scripts is 我在CentOS 6.5的init.d脚本中看到了很多奇怪的怪癖,但是在大多数这些脚本的结尾我看到的一种模式是
case "$1" in
# ... commands here
esac
exit $?
What is the purpose of " exit $?
" here? 这里“
exit $?
”的目的是exit $?
?
It makes the script return the return code of the last significant command to the calling init system. 它使脚本将最后一个有效命令的返回码返回到调用init系统。 Whenever a command exits, its return code is stored on
$?
每当命令退出时,其返回代码都存储在
$?
上$?
by the shell. 靠壳。
It's actually not really necessary to explicitly specify $?
实际上并没有必要显式指定
$?
but scripters probably just include it to be clear about what it intends to do. 但是脚本编写者可能只是将其包括在内,以明确其打算做什么。
exit: exit [n]
退出:退出[n]
Exit the shell.
退出外壳。
Exits the shell with a status of N. If N is omitted, the exit status is that of the last command executed.
退出状态为N的Shell。如果省略N,则退出状态为最后执行的命令的状态。
I also hope you don't actually mean eend $?
我也希望您实际上不是要
eend $?
of OpenRC
: OpenRC
:
eend retval [string ]
eend retval [字符串]
If retval does not equal 0 then output the string using eerror and !!
如果retval不等于0,则使用eerror和!!输出字符串。 in square > brackets at the end of the line.
在行末的方括号中。 Otherwise output ok in square brackets at the end of the line.
否则,在行尾的方括号中输出ok。 The value of retval is returned.
返回retval的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.