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."
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!