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: Chet Ramey
Subject: Re: different exit codes in $? and ${PIPESTATUS[@]}
Date: Fri, 12 Oct 2012 17:04:45 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20120907 Thunderbird/15.0.1

On 10/10/12 10:38 AM, Wladimir Sidorenko wrote:
> Dear all,
> 
> After running the following command:
> 
> $  ! test 0 -eq 0
> 
> I can see different exit codes in $? and ${PIPESTATUS[@]}. Here, what I get
> 
> $ ! test 1 -eq 0 ; echo $? ${PIPESTATUS[@]}
> 0 1
> 
> $ ! test 0 -eq 0 ; echo $? ${PIPESTATUS[@]}
> 1 0
> 
> I'd like to know whether that's a desired behavior or a bug.

The current behavior is the intended behavior.  PIPESTATUS reflects the
"true" return status(es) of the process(es) in the pipeline, before any
inversion of the pipeline's exit status.  That's what seems the most
useful.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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