I have a parent function and child function:
parent() {
child aa1 bb1 cc1
child aa2 bb2 cc2
child aa3 bb3 cc3
child aa4 bb4 cc4
}
child() {
....
if [ some error reason ]; then return 1; fi
...
}
How to make the return 1
(of the child) cause a return in the parent and then avoid the execute the remaining child calls?
without adding a check of the returned value after each child call like this
parent() {
child aa1 bb1 cc1
e=$?; [ "$e" != "0" ] && return $e
child aa2 bb2 cc2
e=$?; [ "$e" != "0" ] && return $e
child aa3 bb3 cc3
e=$?; [ "$e" != "0" ] && return $e
child aa4 bb4 cc4
e=$?; [ "$e" != "0" ] && return $e
}