⬅︎ Back to How to intercept and react to non-zero exits in bash
`./script/update-internal-links.js --check || echo "Extra message here informing that the script failed"`Is more concise imo. If the initial return value isn’t 0, the script will echo your message, which will have an exit value of 0.
What if you have many things you want to do, if it failed. Not just 1 single `echo`. Yes, you could use brackets but it'll get a bit messy. And the remit is to intercept failure, do something with that fact, but still exit with the same exit code as the original script.
Comment
`./script/update-internal-links.js --check || echo "Extra message here informing that the script failed"`
Is more concise imo. If the initial return value isn’t 0, the script will echo your message, which will have an exit value of 0.
Replies
What if you have many things you want to do, if it failed. Not just 1 single `echo`.
Yes, you could use brackets but it'll get a bit messy.
And the remit is to intercept failure, do something with that fact, but still exit with the same exit code as the original script.