Jeff King wrote: > FreeBSD's /bin/sh doesn't propagate $? over an eval Thanks for tracking it down. > Looking at that patch, I don't see any reason that eval_ret needs to be > set inside the eval. If we have multiple test_when_finished calls, we > keep setting and propagating eval_ret, which doesn't make much sense to > me. Why not just: > > test_run_ () { > test_cleanup= > eval >&3 2>&4 "$1" > eval_ret=$? > eval >&3 2>&4 "$test_cleanup" > return 0 > } > > test_when_finished () { > test_cleanup="$*; $test_cleanup" > } > > Am I missing something? If cleanup fails, I want to catch it. Would something like this do? test_run_ () { test_cleanup=: eval >&3 2>&4 "$1" eval_ret=$? eval >&3 2>&4 "$test_cleanup" && (exit "$eval_ret") eval_ret=$? return 0 } test_when_finished () { test_cleanup="$* && $test_cleanup" } To permit a line break at the end of a cleanup command, one can do test_when_finished () { test_cleanup="{ $* } && $test_cleanup" } but that might not be worth the ugliness. Jonathan -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html