bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: different exit codes in $? and ${PIPESTATUS[@]}


From: Eric Blake
Subject: Re: different exit codes in $? and ${PIPESTATUS[@]}
Date: Fri, 12 Oct 2012 15:40:56 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121009 Thunderbird/16.0

On 10/12/2012 03:36 PM, Wladimir Sidorenko wrote:
> Ok, thanks. I'll notice this for the future. It's of course arguable,
> whether PIPESTATUS stores a true value, since the '!' inversion
> keyword gets ignored in this case. But if it was intended, than it's
> ok.

Consider:

$ f() { return 2; }
$ ! f
$ echo $? ${PIPESTATUS[@]}
0 2

If PIPESTATUS included the effect of !, you would only ever be able to
see 0 or 1; but by having it be the uninverted status, you can see the
full 0-255 of the actual command prior to the inversion.

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]