Date: Mon, 8 Nov 1999 20:19:14 -0500 (EST) From: "Crist J. Clark" <cjc@cc942873-a.ewndsr1.nj.home.com> To: wjm@gate.net (William Melanson) Cc: sl@zeus.dnt.md (slava revutchi), freebsd-questions@FreeBSD.ORG Subject: Re: shell's exit status variable Message-ID: <199911090119.UAA39447@cc942873-a.ewndsr1.nj.home.com> In-Reply-To: <Pine.A41.4.03.9911081423040.59796-100000@tiwa.gate.net> from William Melanson at "Nov 8, 1999 02:26:28 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
William Melanson wrote, > On Mon, 8 Nov 1999, slava revutchi wrote: > > % > % Hello, > % > % How do I check the shell's exit status variable? > % > % Thanks. > % slava > % > > I know within the bash shell it would be as such: > > >[script]; echo $? > > The "$?" varaible prints the exit status of the last command run. > Either a "1" or "0". Actually I believe the return can be any int value. Many commands exit with different non-zero values depending on what type error was generated. Two quick examples, % man dump ... Dump exits with zero status on success. Startup errors are indicated with an exit code of 1; abnormal termination is indicated with an exit code of 3. ... % man grep ... Normally, exit status is 0 if matches were found, and 1 if no matches were found. (The -v option inverts the sense of the exit status.) Exit status is 2 if there were syn- tax errors in the pattern, inaccessible input files, or other system errors. ... However, '0' is the accepted value for "success," non-zero is "failure." -- Crist J. Clark cjclark@home.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199911090119.UAA39447>