Re: Question with $? in bash, with chains of commands
%% Mike Dresser <mdresser_l@windsormachine.com> writes:
md> Here's a code fragment i'm trying to work on in bash
md> The problem is, $? reports the result of the last command, which
md> is gzip, which will ALWAYS report 0(well, unless the hd is full or
md> the moon is full),
Yes. The definition of $? in the Bourne shell, since forever, is that
it is the exit code of the last program invoked in a pipeline.
md> Anyone have any ideas?
See the PIPESTATUS variable in the bash man page.
Note that this is not a standard thing, so if you use it your script
may not be portable to other Bourne-like shells.
--
-------------------------------------------------------------------------------
Paul D. Smith <pausmith@nortelnetworks.com> HASMAT--HA Software Mthds & Tools
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
These are my opinions---Nortel Networks takes no responsibility for them.
--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: