[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PIPESTATUS differs from $? for compound command
From: |
Chet Ramey |
Subject: |
Re: PIPESTATUS differs from $? for compound command |
Date: |
Tue, 10 Dec 2024 17:10:08 -0500 |
User-agent: |
Mozilla Thunderbird |
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 chet@case.edu http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature
- Re: PIPESTATUS differs from $? for compound command, (continued)
- Re: PIPESTATUS differs from $? for compound command, Mike Jonkmans, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Andreas Schwab, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, microsuxxor, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Ulrich Müller, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, microsuxxor, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Mike Jonkmans, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Phi Debian, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command,
Chet Ramey <=
- Re: PIPESTATUS differs from $? for compound command, Mike Jonkmans, 2024/12/11
- Re: PIPESTATUS differs from $? for compound command, Andreas Schwab, 2024/12/11
- Re: PIPESTATUS differs from $? for compound command, Lawrence Velázquez, 2024/12/11
- Re: PIPESTATUS differs from $? for compound command, Mike Jonkmans, 2024/12/12
- Re: PIPESTATUS differs from $? for compound command, Lawrence Velázquez, 2024/12/12
- Re: PIPESTATUS differs from $? for compound command, Mike Jonkmans, 2024/12/12
- Re: PIPESTATUS differs from $? for compound command, microsuxxor, 2024/12/12
- Re: PIPESTATUS differs from $? for compound command, Chet Ramey, 2024/12/12
- Re: PIPESTATUS differs from $? for compound command, Greg Wooledge, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Ulrich Müller, 2024/12/10