Prevent bash from printing "<PID> Cancel" messages
I have a test script that launches a small application again and 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 good and good, except when it fails. I get two messages, the βERRORβ message that I want, and then another (apparently from bash?), Warning me that my application was interrupted:
test_script.sh: line 10: 641 Aborted ./my_app $input1 $input2 ERROR: app failed with inputs: XXX YYY How to prevent interrupted messages?
Also note: the application probably does not work in the standard assert statement of the C library.
I also came across this. It seems that bash itself prints it unilaterally if the child process returns with a status code of 134, indicating the recipient received SIGABRT . The solution is to start the child process in the subshell, and then ensure that the subshell returns a different (still non-zero) status code upon failure and redirects its output to /dev/null . For example:
if ! ( ./myapp || false ) >/dev/null 2>&1; then ... fi You should probably not suppress the error message. Instead of having your script emit an error message and suppress the error from the application, the script did not say anything and will report an application error message. If you do not like the error message from the application, correct it in the application, and do not try its script.