MLUG: Re: [MLUG] basic Unix pipe/exit code problem
Re: [MLUG] basic Unix pipe/exit code problem
Email address obfuscation in effect -- please click here to turn it off.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
On Thu, 3 Mar 2005 12:24:49 -0600, Mark Rages <EMAIL:PROTECTED> wrote: 
> I have reduced my problem to this:
> 
> ( /bin/false | gzip > /dev/null ) || echo fail
> 
> I want it to echo "fail" because /bin/false gives a nonzero exit code.
>  But it doesn't.  What am I missing?

Google "PIPESTATUS" or search for it in the bash man page. 

       PIPESTATUS
              An  array  variable (see Arrays below) containing a list of exit
              status values from the processes in  the  most-recently-executed
              foreground pipeline (which may contain only a single command).


Scott-Husseys-Computer:~/dev/html scott$ false | gzip > /dev/null
Scott-Husseys-Computer:~/dev/html scott$ echo ${PIPESTATUS[*]}
1 0

-- 
Scott Hussey
EMAIL:PROTECTED
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members