Please use ***[code][/code]
*** tags around your code and data, to preserve the original formatting and to improve readability. Do not
use quote tags, bolding, colors, "start/end" lines, or other creative techniques.
I personally would set the warning up as a function, and use a for loop instead.
mplayer /path/to/alarm.wav &
for (( R=10; R>=0; R--)); do
echo "there is an error..."
if (( $? == 0 )); then
echo "everythings ok."
The c-style for loop and the ((..)) arithmetic evaluation brackets are bash/ksh specific, however.