我有一个父函数和子函数:
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
...
}
如何制作return 1
(孩子的)在父母中引起回报,然后避免执行剩余的孩子电话?
没有像这样在每个子调用之后添加对返回值的检查
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
}