I've got a test script that runs a small app over and over again with various inputs:
# test_script.sh
for input1 in $some_range; do
for input2 in $some_other_range; do
if ! ./my_app $input1 $input2 2>/dev/null; then
echo "ERROR: app failed with inputs: $input1 $input2"
fi
done
done
This is all well and good, except when it fails I get two messages, the 'ERROR' message I want, and then another (apparently from bash?) alerting me that my app was aborted:
test_script.sh: line 10: 641 Aborted ./my_app $input1 $input2
ERROR: app failed with inputs: XXX YYY
How do I prevent the 'Aborted' messages?
Also note: The app is probably failing on a standard C library 'assert' statement.
I just ran into this too. It seems that bash
itself prints this unilaterally if a child process returns with status code 134, indicating the child recieved SIGABRT
. The solution is to run the child process in a subshell, then ensure the subshell returns a different (still non-zero) status code on failure and has its output redirected to /dev/null
. For example:
if ! ( ./myapp || false ) >/dev/null 2>&1; then
...
fi
Try disabling job control:
set +m
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With