Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: { foo=bar; command; } | othercommand; echo $foo == no output?



On Thu, 19 Apr 2001, Andre Pang wrote:

> I have a problem,  I want to tee and still get the return code:
>
>   prog  x y z | tee
>   echo $?
>

In recent enough zsh (4.0.1-pre-3 is the latest version) you can use
$pipestatus:

pipestatus <S> <Z>
     An array containing the exit values returned by all commands in the
     last pipeline.

bor@itsrm2:~%> cat /foo/bar | tee
cat: Cannot open /foo/bar: No such file or directory
bor@itsrm2:~%> print $pipestatus
2 0

-andrej





Messages sorted by: Reverse Date, Date, Thread, Author