I am writing a bash function.
How do I make the control exit the function as soon as any command in it error out?
I have tried this:
function myFunc() {
set +e
cmd1
cmd2
set -e
}
It works but it closes my terminal as well.
Appreciate any ideas.
Thanks.
cmd1 || return; cmd2 || return?