Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ucbvax!ucbcad!scheme.Berkeley.EDU!sarge From: sarge@scheme.Berkeley.EDU (Steven Sargent) Newsgroups: comp.lang.c Subject: Re: exit(-1), 0 is sometimes magic Keywords: exit, zero, flaming Message-ID: <2220@ucbcad.berkeley.edu> Date: 22 Jan 88 02:28:09 GMT References: <1234@nmtsun.nmt.edu> <502@cresswell.quintus.UUCP> <6935@brl-smoke.ARPA> <1179@wjvax.UUCP> <2305@bloom-beacon.MIT.EDU> Sender: news@ucbcad.berkeley.edu Lines: 20 The UNIX shells absolutely enforce the 0 vs. nonzero exit status distinction. 1. The usages (Shell) if cmdlist; then stuff; else stuff; fi (csh) if ({cmd}) then stuff; else stuff; endif along with their loop analogues, make the decision based on exit status of cmd (or of the last command in cmdlist). 2. The Shell's operators && and || also work this way, i.e., in foo && bar bar is executed only if foo exits happily. 3. The Shell has a command-line option (-e) that causes a script to exit whenever a command exits nonzeroly. All this (and more, I'm sure; but csh is of less interest to me in this context) is available in the relevant manual pages. S.