Weird one, so the following will not log "bash exit code..."
#!/usr/bin/env bash OUTPUT_PATH=${PROJECT_ROOT:-$PWD}/npm-install-output.log npm --loglevel=warn --progress=false install > ${OUTPUT_PATH} 2>&1 && export NODE_PATH=${NODE_PATH}:~/.suman/node_modules && node $(dirname "$0")/test.js && EXIT=$? && echo " " && # newline echo "bash exit code => $?" && exit ${EXIT} if I remove one "&&" after the node command like so:
#!/usr/bin/env bash OUTPUT_PATH=${PROJECT_ROOT:-$PWD}/npm-install-output.log npm --loglevel=warn --progress=false install > ${OUTPUT_PATH} 2>&1 && export NODE_PATH=${NODE_PATH}:~/.suman/node_modules && node $(dirname "$0")/test.js # <<<<< removed "&&" chars EXIT=$? && echo " " && # newline echo "bash exit code => $?" && exit ${EXIT} then the node process will exit with a non-zero code, but then bash says:
bash exit code => 0
both of these are not giving correct results, there is something wrong with my code. I want to capture the correct exit code of the node process, and I want to print it out! What could be wrong?