From: Stephen Shirley (diamond at domain skynet.ie)
Date: Fri 14 Jun 2002 - 12:12:50 IST
Mornin' all,
The following bash script fails to work as expected/desired:
---------------------------------
#!/bin/bash
function sleep_60 () {
trap return 2
echo 'Died.....restarting in 60....',`trap`
i=0
while [ $i -lt 60 ]; do
echo -n '.'
i=$((i+1))
sleep 1
done
}
while true; do
#do stuff
sleep_60
done
---------------------------------
It's supposed to allow ctrl-c to be pressed during the sleep_60 function, which
should just return, and all it well. However, it only works the first time. The
next time sleep_60 is called, the ctrl-c only seems to kill the 'sleep 1'. This
is on rh 7.3 + bash 2.05a.0(1)-release, rh 6.1 + bash 1.14.7(1), and debian
woody + bash 2.05a.0(1)-release.
So, can anyone see any problems with the above script, or is it actually a bash
bug (or even something else)?
Steve
-- "Oh look, it's the Pigeon of Love."
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:17:15 GMT