[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 16:53:43 -0500 |
User-agent: |
Mozilla Thunderbird |
On 12/9/24 12:21 PM, Ulrich Müller wrote:
Bash Version: 5.2
Patch Level: 37
Release Status: release
Description:
For a compound command like "if" or "while" and with
an unsuccessful test, the last element of PIPESTATUS is not the
return status of the compound but that of the test command.
For example, "if false; then :; fi" returns 0 but ${PIPESTATUS[0]}
is 1.
Compound commands don't generally set PIPESTATUS. Multi-element pipelines
(the original purpose, because otherwise why bother), simple commands
(single-element pipelines) including shell builtins, and compound commands
that resemble simple commands (`[[', `((') set it.
Yes, you can make the case that compound commands are pipelines, and,
according to the grammar, they are, but their status is always available
in $?, and they never have more than one status value.
--
``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/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
Re: PIPESTATUS differs from $? for compound command,
Chet Ramey <=
Re: PIPESTATUS differs from $? for compound command, Dale R. Worley, 2024/12/11