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

Re: Saving error return code in a pipeline



On Thu, Jun 30, 2005 at 11:33:07AM +0200, DervishD wrote:
>     Hi all :)
> 
>     Maybe I'm asking for something impossible, or maybe I'm just dumb
> enough to not see the obvious solution...
> 
>     I have a script which returns an error code, but it outputs a lot
> of info, so I call it like this:
> 
>     script.install |& tee install.log
> 
>     Obviously this 'masks' the return code, but I want to see the
> output even though I'm saving it to a file, so a redirection doesn't
> fit me well. I can use MULTIOS, of course, but I don't want to use it
> for all my commands...
> 
>     Is there any better solution than this?:
> 
>     script.install >(tee install.log) 2>&1

Try looking at the pipestatus array.  It contains all the exit codes
from the last pipeline.  So you should be able to get the code you want
by examining $pipestatus[1].

-Dom



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