[Techtalk] Shell script question
mariab at cats.meow.at
Mon Feb 24 18:51:24 EST 2003
On Mon, 24 Feb 2003, Jennifer Davis wrote:
> I write a shell script modelled on the National Capital Freenet that runs
> on from .bash_login. It seems to be going fine, except that I don't want
> people to do a control-c and get a shell prompt. Does anyone know the
> code to ensure that people cannot escape the menus?
What you need to do is trap SIGINT.
SIGINT is the interrupt signal, and is generated when you press Ctrl-C
in bash, the command to do this in a shell script is "trap"
trap <command> <signal>
where the command is what to do when the signal is caught, and signal is
the signal, eg:
trap "echo You can check out any time, but you can never leave!" SIGINT
would print "You can check out any time, but you can never
leave!" whenever they pressed Ctrl-C
Trapping signals for fun and profit :)
More information about the Techtalk