Subject: Re: Returned values in shell scripts
To: Andy Ball <ball@cyberspace.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: netbsd-users
Date: 07/06/2002 18:53:54
On Sat, 6 Jul 2002, Andy Ball wrote:

> If I call a program (I'm thinking of xmessage initially,
> but it would be helful to know in general), and that
> program returns an exit value, how do I access that in
> the next line of the shell script?  Is it stuffed in an
> environment variable somewhere?

Yes. Look at $? with sh and bash.

With csh look at $status.

xmessage can return different values.

% xmessage good -buttons yes,no
% echo $status
102

Then use test(1) or whatever.

   Jeremy C. Reed
   http://www.reedmedia.net/