[ale] Exiting multi-block shell scripts
Danny Cox
danny at compgen.com
Wed Jun 28 08:39:07 EDT 2000
Kenneth,
On Wed, 28 Jun 2000, Kenneth W Cochran wrote:
> Whoops... Late-night lack of clear question-asking... :) :/
>
> I tried "exit." :)
>
> What I Want To Do is be able to control-c out of this thing
> "anywhere." Best I've been able to do so far is that I have to
> ^C twice. I guess I should also mention that the "do" object(s)
> are series of commands (more specifically, I'm trying to
> quickie-ping an address-range...)
Try 'trap'. Syntax is: trap cmd sigs. For your purpose:
trap 'exit 0' 1 2 3 15
Then, when/if the script gets a SIGHUP, SIGINT, SIGQUIT or
SIGTERM, it will execute the 'exit 0'. There is also a psuedo
signal #0, which means 'on exit'. I've used this feature many times to
remove temporary files on the above signals, and on exit. Pretty handy.
Danny
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
More information about the Ale
mailing list