Date: Mon, 8 Nov 1999 23:12:49 +0000 From: Ben Smithurst <ben@scientia.demon.co.uk> To: William Melanson <wjm@gate.net> Cc: slava revutchi <sl@zeus.dnt.md>, freebsd-questions@FreeBSD.ORG Subject: Re: shell's exit status variable Message-ID: <19991108231249.A3075@strontium.scientia.demon.co.uk> In-Reply-To: <Pine.A41.4.03.9911081423040.59796-100000@tiwa.gate.net> References: <Pine.BSF.4.05.9911081928230.61689-100000@zeus.dnt.md> <Pine.A41.4.03.9911081423040.59796-100000@tiwa.gate.net>
next in thread | previous in thread | raw e-mail | index | archive | help
William Melanson wrote:
> On Mon, 8 Nov 1999, slava revutchi wrote:
>
> % How do I check the shell's exit status variable?
>
> 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".
It can be a lot more than that. It can be any value from 0 to 255
inclusive, although as you say zero and one are probably the most common
(since they correspond to the EXIT_SUCCESS and EXIT_FAILURE constants,
respectively).
Note that if $? is greater than 128, it *might* mean that the process was
terminated by signal ($? - 128), e.g.
ben@strontium:~/work/ifonline$ sleep 20
^C
ben@strontium:~/work/ifonline$ echo $?
130
130 - 128 = 2, which corresponds to SIGINT, delivered by me pressing
ctrl-C. This 128+sig business is just a convention used by shells
though and cannot really be relied on.
--
Ben Smithurst | PGP: 0x99392F7D
ben@scientia.demon.co.uk | key available from keyservers and
| ben+pgp@scientia.demon.co.uk
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?19991108231249.A3075>
