我有一个Bash脚本,它运行节点脚本作为其任务的一部分.我希望bash脚本以与节点脚本相同的退出代码退出.以下是简化示例.
foo.sh:
#!/bin/bash
node ./bar.js
bar.js:
process.exit(1); //sometimes the exit code can be 0
解决方法:
来自:http://www.tldp.org/LDP/abs/html/exit-status.html
When a script ends with an exit that has no parameter, the exit status of the script is the exit status of the last command executed in the script
这意味着您只需要在上面的脚本中添加“exit”.
#!/bin/bash
node ./bar.js
exit
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。