[comp.unix.questions] exit codes

generous@dgis.daitc.mil (Curtis Generous) (08/18/89)

Has there ever been a consensus about what a `well-behaved` UN*X program
should return in both normal and error conditions.  Examples of what I mean:

	% mesg >& /dev/null; echo $status
	13

	% crypt junk < /tmp/f > /tmp/f2; echo $status
	-1

	...many others...

I got bit last night with one of those off-the-wall ones (sorry chris), and
can't help thinking that there has to be some guidelines to use on picking
exit codes, other than `exit(0) for normal termination, anything else you 
want otherwise`.

--curtis
-- 
Curtis C. Generous
DTIC Special Projects Office (DTIC-SPO)
ARPA: generous@daitc.mil
UUCP: {uunet,vrdxhq}!dgis!generous

karish@forel.stanford.edu (Chuck Karish) (08/18/89)

In article <33@dgis.daitc.mil> generous@dgis.daitc.mil (Curtis Generous) wrote:
>Has there ever been a consensus about what a `well-behaved` UN*X program
>should return in both normal and error conditions.

No.

The exit status values for most utilities aren't documented at
all in UN*X manuals.  The POSIX 1003.2 committee is standardizing
returns.  Until their work is accepted, it will be an adventure to use
utility return values in scripts that are meant to be portable.

	Chuck Karish		karish@mindcraft.com
	(415) 493-9000		karish@forel.stanford.edu