home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ukma!wupost!usc!randvax!ucla-an!daveh
- From: daveh@ucla-an.UUCP (Dave Hammond)
- Newsgroups: comp.unix.shell
- Subject: Re: REALLY trapping INT
- Message-ID: <219@ucla-an.UUCP>
- Date: 13 Dec 92 16:56:21 GMT
- References: <ByvExM.3Hv@techbook.com>
- Reply-To: daveh@ucla-an.UUCP (Dave Hammond)
- Organization: Anesthesia Dept., Sch. of Medicine, UCLA, Los Angeles
- Lines: 37
-
- >In <ByvExM.3Hv@techbook.com> jamesd@techbook.com (James Deibele) writes:
- >
- >>I've got some newbies that I'd like to put into a menu. No problem,
- >>I'll write a shell program and use that as their login shell. They can
- >>still use all the UNIX commands, but I can show them what to do on
- >>different menu pages.
- >
- >>Hmmm. ^C kills the program they're running all right, but it also kills
- >>the menu shell.
-
- Presuming the menu shell is a looping sh/ksh/bash script, calling
-
- trap : 2
-
- will protect the menu shell from interrupts. For example:
-
- while :
- do
- trap : 2
- echo enter yor choice
- read answer
- case $answer in
- 1) foo ;;
- 2) bar ;;
- 99) break ;;
- esac
- done
- exit
-
- Hitting (or leaning on :-) the interrupt key at either the menu or
- child program level will not affect the menu shell.
-
- Hope this helps.
-
- --
- Dave Hammond
- daveh@anes.ucla.edu
-