I have the following situation. Script A source script B. Script B has a function named check, which does no error handling on any of its executed commands.
check () {
cmd1
cmd2
cmd3
...
}
My goal is to call the function check from A, exiting if any of cmd* fails.
I have tried from A "check || exit 1" but if cmd2 fails and cmd3 succeeds, A does not exit. set -e did not do the job for me as well.
Any help is appreciated.
set -eseems to work for me. Please, give us more details.cmd1 && cmd2 && cmd3 ...in check, "check || exit 1" should work then.