home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / shell / 5341 < prev    next >
Encoding:
Internet Message Format  |  1993-01-11  |  1.0 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!ogicse!pnl-oracle!aggie!d3a061
  2. From: d3a061@aggie.oname (ZT Taylor)
  3. Newsgroups: comp.unix.shell
  4. Subject: Bourne shell functions; what of 'exit'?
  5. Message-ID: <1993Jan11.165425.7692@oracle.pnl.gov>
  6. Date: 11 Jan 93 16:54:25 GMT
  7. Article-I.D.: oracle.1993Jan11.165425.7692
  8. Sender: news@oracle.pnl.gov
  9. Reply-To: zt_taylor@pnl.gov
  10. Organization: Pacific Northwest Laboratory
  11. Lines: 31
  12.  
  13. Bourne shell functions seem to be inconsistent in the way they handle an 'exit'
  14. statement.  For example, the following:
  15.  
  16.     func() {
  17.         .
  18.         .
  19.         exit 1
  20.     }
  21.  
  22.     func
  23.  
  24. causes the whole shell script to exit, while this:
  25.  
  26.     func() {
  27.         .
  28.         .
  29.         exit 1
  30.     }
  31.  
  32.     junk=`func`
  33.     echo $?
  34.  
  35. doesn't.  At first I thought this meant func was executed in a subshell, but
  36. echoing $$ both places gives the same PID.  Is this context-sensitive treatment
  37. of 'exit' a feature?  Can it be counted on in portable scripts?
  38.  
  39. Unless flamed for the stupidity of my question, I will summarize.
  40.  
  41. Todd Taylor
  42. Pacific Northwest Laboratory
  43. zt_taylor@pnl.gov
  44.