Andreas Schwab <[email protected]> writes:
>> But the PIPESTATUS refers to the 'false' pipeline:
>> $ if false; then :; fi; echo ${PIPESTATUS[*]}
>> 1
>
> $ if false; then :; fi | true; echo ${PIPESTATUS[*]}
> 0 0
>
> Why is that not `1 0'? After all, the last executed commands as part of
> the pipeline (by your reasoning) are `false' and `true'.
It looks complicated:
$ if false; then :; fi | true; echo ${PIPESTATUS[*]}
0 0
$ if false; then :; fi | true; echo $?
0
$ if false; then :; fi ; echo ${PIPESTATUS[*]}
1
$ if false; then :; fi ; echo $?
0
I'm sure there's an explanation, but I'm not feeling up to spelunking
through the documentation enough to figure it out.
Dale