I have a Bash script which runs a node script as part of its tasks. I would like the bash script to exit with the same exit code as the node script. Simplified example below.
foo.sh:
#!/bin/bash
node ./bar.js
bar.js:
process.exit(1); //sometimes the exit code can be 0
From: 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
which implies that you simply need to add "exit" to your above script.
#!/bin/bash
node ./bar.js
exit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With