help with pipes

Jan Dvorak jan.dvorak at sitronicsts.com
Mon Feb 23 00:26:42 PST 2009


On Sunday 22 February 2009 03:13:19 Robert Connolly wrote:
> Hello. As mentioned before, I have a problem with:
> bzcat ../loop-AES-v3.2e-20090112.diff.bz2 | patch -p1 &&
>
> The && is useless because of the |. I think the && is using the return
> value from bzcat, and not from patch. Redirection would work, except
> that the patch is bzip2 compressed. For example:
> patch -p1 < ../loop-AES-v3.2e-20090112.diff
> works, but
> patch -p1 < $(bzcat ../loop-AES-v3.2e-20090112.diff.bz2)
> does not (ambiguous redirect).
>
> Is there another way, aside from decompressing the patch in the sources
> directory?

bzcat ../loop-AES-v3.2e-20090112.diff.bz2 | patch -p1 &&

Will extract, but the exit code taken into account would be that of patch. 
So, to make sure you take both exit codes into account, you have to use:

false | true && expr ${PIPESTATUS[0]} = 0

Or something similar.



More information about the hlfs-dev mailing list