home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!ogicse!pnl-oracle!aggie!d3a061
- From: d3a061@aggie.oname (ZT Taylor)
- Newsgroups: comp.unix.shell
- Subject: Bourne shell functions; what of 'exit'?
- Message-ID: <1993Jan11.165425.7692@oracle.pnl.gov>
- Date: 11 Jan 93 16:54:25 GMT
- Article-I.D.: oracle.1993Jan11.165425.7692
- Sender: news@oracle.pnl.gov
- Reply-To: zt_taylor@pnl.gov
- Organization: Pacific Northwest Laboratory
- Lines: 31
-
- Bourne shell functions seem to be inconsistent in the way they handle an 'exit'
- statement. For example, the following:
-
- func() {
- .
- .
- exit 1
- }
-
- func
-
- causes the whole shell script to exit, while this:
-
- func() {
- .
- .
- exit 1
- }
-
- junk=`func`
- echo $?
-
- doesn't. At first I thought this meant func was executed in a subshell, but
- echoing $$ both places gives the same PID. Is this context-sensitive treatment
- of 'exit' a feature? Can it be counted on in portable scripts?
-
- Unless flamed for the stupidity of my question, I will summarize.
-
- Todd Taylor
- Pacific Northwest Laboratory
- zt_taylor@pnl.gov
-