home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / shell / 5048 < prev    next >
Encoding:
Internet Message Format  |  1992-12-13  |  1.2 KB

  1. Path: sparky!uunet!ukma!wupost!usc!randvax!ucla-an!daveh
  2. From: daveh@ucla-an.UUCP (Dave Hammond)
  3. Newsgroups: comp.unix.shell
  4. Subject: Re: REALLY trapping INT
  5. Message-ID: <219@ucla-an.UUCP>
  6. Date: 13 Dec 92 16:56:21 GMT
  7. References: <ByvExM.3Hv@techbook.com>
  8. Reply-To: daveh@ucla-an.UUCP (Dave Hammond)
  9. Organization: Anesthesia Dept., Sch. of Medicine, UCLA, Los Angeles
  10. Lines: 37
  11.  
  12. >In <ByvExM.3Hv@techbook.com> jamesd@techbook.com (James Deibele) writes:
  13. >
  14. >>I've got some newbies that I'd like to put into a menu.  No problem,
  15. >>I'll write a shell program and use that as their login shell.  They can
  16. >>still use all the UNIX commands, but I can show them what to do on
  17. >>different menu pages.
  18. >
  19. >>Hmmm.  ^C kills the program they're running all right, but it also kills
  20. >>the menu shell.
  21.  
  22. Presuming the menu shell is a looping sh/ksh/bash script, calling
  23.  
  24. trap : 2
  25.  
  26. will protect the menu shell from interrupts.  For example:
  27.  
  28. while :
  29. do
  30.     trap : 2
  31.     echo enter yor choice
  32.     read answer
  33.     case $answer in
  34.     1) foo ;;
  35.     2) bar ;;
  36.     99) break ;;
  37.     esac
  38. done
  39. exit
  40.  
  41. Hitting (or leaning on :-) the interrupt key at either the menu or
  42. child program level will not affect the menu shell.
  43.  
  44. Hope this helps.
  45.  
  46. --
  47. Dave Hammond
  48. daveh@anes.ucla.edu
  49.