[CentOS] Getting the return value of the last command run

Tue May 31 01:24:53 UTC 2011
Robert Nichols <rnicholsNOSPAM at comcast.net>

On 05/30/2011 05:14 PM, fred smith wrote:
> Yes, all commands return a value UNLESS it was written by one of the
> idi,... er, misguided programmers who thinks its ok to write (in
> C):
> void main (void)
> 	{
> 	...
> 	exit();
> 	}
> because, of course, in C main() always returns SOMETHING.
> I'm sure it's the same in a bash script, even if the script doesn't
> explicitly provide a return value I imagine the shell returns something
> anyway, it's just that it's meaningless when that happens.

In a bash script, "exit" with no parameter and just falling off the end
of the script are both equivalent to "exit $?" and return the status
from the last command or shell construct executed in the script.

Bob Nichols     "NOSPAM" is really part of my email address.
                 Do NOT delete it.