How to write a condition in Bourne shell
Giorgos Keramidas
keramida at ceid.upatras.gr
Mon Nov 5 04:03:06 PST 2007
On 2007-11-05 14:03, Olivier Nicole <on at cs.ait.ac.th> wrote:
> Hi,
>
> I am a lame Bourne sheel programmer, how to write:
>
> while [ ( $? -ne 0 ) -a ( $retry -gt 0 ) ] ; do
>
> that should execute as long as $? is not null and $retry is greater
> than 0?
Try something like...
retry=0
done=-0
while [ $done -eq 0 ] && [ $retry -lt 10 ]; do
run_some_other_stuff_here
if [ $? -eq 0 ]; then
done=1
fi
done
if [ $done -eq 0 ]; then
echo "Failed after $retry attempts."
fi
More information about the freebsd-questions
mailing list