On 12/10/24 4:41 AM, Mike Jonkmans wrote:

Also compare:
        $ if false; then echo foo; fi
        $ echo "ret = $?, status = ${PIPESTATUS[*]}"
        ret = 0, status = 1
To:
        $ if ! :; then echo foo; fi
        $ echo "ret = $?, status = ${PIPESTATUS[*]}"
        ret = 0, status = 0

The '! :' is a pipeline with status = 1.
Yet it is not reflected in PIPESTATUS.

OK, extend that. The `!' applies to the pipeline, not necessarily to all
the commands in it, since the status of a pipeline is the status of the
last element (ignore pipefail for now).

So, given

! true | false

how should the negation be reflected in the values assigned to PIPESTATUS?

Since one use of PIPESTATUS is to find out which pipeline element(s)
succeeded and which failed, how is modifying some element of PIPESTATUS
here helpful?

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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to