We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exit命令用于退出当前的shell, 如果发现exit无法直接退出整个脚本, 则表示使用了类似$(),管道符|,` ` 等方式, 而此类方式将吊起一个子shell, 此时的exit命令只对该子shell有效. 除了用一定的方式重写函数exit, 最方便的方式是在脚本开始处设置set -e 即可实现只要后续指令传回值不等于0(即命令运行出错)就直接终止整个脚本的运行
exit
$()
|
` `
子shell
set -e
关于set命令的用法详见: https://wangchujiang.com/linux-command/c/set.html
set
注意: 在脚本开始处设置set -e 也会误伤一些需要正常错误退出的命令, 故并不建议使用.
最好的解决方法 待续...
待续...
The text was updated successfully, but these errors were encountered:
No branches or pull requests
exit
命令用于退出当前的shell, 如果发现exit
无法直接退出整个脚本, 则表示使用了类似$()
,管道符|
,` `
等方式, 而此类方式将吊起一个子shell
, 此时的exit
命令只对该子shell
有效.除了用一定的方式重写函数
exit
, 最方便的方式是在脚本开始处设置set -e
即可实现只要后续指令传回值不等于0(即命令运行出错)就直接终止整个脚本的运行注意: 在脚本开始处设置
set -e
也会误伤一些需要正常错误退出的命令, 故并不建议使用.最好的解决方法
待续...
The text was updated successfully, but these errors were encountered: