Reputation: 6971
I am getting a non-deterministic crash in a library I am using which occurs a lot less frequently when the library's full debugging is turned on. I want to run it repeatedly until the program crashes, and then look at the detailed debug (let's assume that unit-test-command with args
calls the code I am interested in)
This is the code I have in my script:
#!/bin/bash
while [[ $(unit-test-command with args) == 0 ]]
do
echo ""
done
However, not only does it only go through the loop once irrespective of the return value of the command (which is non-zero when it crashes), but it also only displays the output of my program, and not the output of the library debugging.
What I am doing wrong?
Upvotes: 1
Views: 243
Reputation: 1482
#!/bin/bash
while [ true ];do
unit-test-command with args
if [ $? != 0 ];then
echo "failed"
break
fi
echo "didn't faile
sleep 10
done
Upvotes: 0
Reputation: 543
$(command) expands to the console output, not to return code. For example, uname returns 0 and $(uname) returns "linux".
Try so:
while unit-test-command with args ; do : ; done
Upvotes: 4