bug-bash
[Top][All Lists]
Advanced

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

Re: PIPESTATUS differs from $? for compound command


From: Dale R. Worley
Subject: Re: PIPESTATUS differs from $? for compound command
Date: Mon, 09 Dec 2024 22:30:35 -0500

Andreas Schwab <schwab@linux-m68k.org> 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



reply via email to

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