On 08/11/2010 07:46 AM, Eric Blake wrote: > On 08/11/2010 05:20 AM, Pierre Gaston wrote: >> On Wed, Aug 11, 2010 at 2:18 PM, Peng Yu <pengyu...@gmail.com> wrote: >>> Hi, >>> >>> >>> The following example returns the exit status of the last command in a >>> pipe. I'm wondering if there is a way to inherent non-zero exit status >>> using pipe. That is, if there is any command in a pipe that return a >>> non-zero status, I'd like the whole pipe return a non-zero status. >> >> set -o pipefail > > But be aware that you seldom want to use this globally
A less invasive technique is to inspect the array variable ${pipestat...@]}, which bash maintains for all elements of the previous pipeline. But remember, both pipefail and $PIPESTATUS are bash extensions, and not pure POSIX. -- Eric Blake ebl...@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature