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
> On Tue, 10 Dec 2024, Chet Ramey wrote:
> 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
>>
> On Tue, 10 Dec 2024, Greg Wooledge wrote:
> My own testing:
> hobbit:~$ if true; then (exit 11) | cat; fi
> hobbit:~$ echo "$? ${PIPESTATUS[*]}"
> 0 11 0
> hobbit:~$ if true; then (exit 11) | cat; fi | false
> hobbit:~$ echo "$? ${PIPESTATUS[*]}"
> 1 0 1
> hobbit:~$ while (exit 12); do :;
"Dale R. Worley" writes:
>> $ if false; then :; fi | true; echo ${PIPESTATUS[*]}
>> 0 0
Trying to dissect this:
There are *three* pipelines that are executed:
1) 'if false; then :; fi | true'
2) 'false' (which is a pipeline, which is a list, which is the
conditional of the 'if')
3) 'echo ${PIPES
On Tue, Dec 10, 2024 at 09:28:31 +0100, Ulrich Müller wrote:
> Then what about these?
>
> $ true; case a in esac
> $ echo "ret = $?, status = ${PIPESTATUS[*]}"
> ret = 0, status = 0
>
> $ false; case a in esac
> $ echo "ret = $?, status = ${PIPESTATUS[*]}"
> ret = 0, status = 1
>
> "case a in es
maybe internal cmds dont statisfy it a pipestatus worthy
On Tue, Dec 10, 2024, 9:29 AM Ulrich Müller wrote:
> > On Mon, 09 Dec 2024, Mike Jonkmans wrote:
>
> >> Why is `if false; then :; fi' not a pipeline? It is a command, and the
> >> components of a pipeline are commands.
>
> > It is a p
On Dez 10 2024, Mike Jonkmans wrote:
> With 'if false... fi | true' there are two pipelines:
> 1) false
> 2) (compound command) if | true
There is only one pipeline, consisting of two commands.
--
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D
On Tue, Dec 10, 2024 at 10:42 AM Mike Jonkmans wrote:
> On Tue, Dec 10, 2024 at 09:28:31AM +0100, Ulrich Müller wrote:
> > > On Mon, 09 Dec 2024, Mike Jonkmans wrote:
> >
> > >> Why is `if false; then :; fi' not a pipeline? It is a command, and
> the
> > >> components of a pipeline are comma
On Mon, Dec 09, 2024 at 11:33:02PM +0100, Andreas Schwab wrote:
> On Dez 09 2024, Mike Jonkmans wrote:
>
> > 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 i
> On Mon, 09 Dec 2024, Mike Jonkmans wrote:
>> Why is `if false; then :; fi' not a pipeline? It is a command, and the
>> components of a pipeline are commands.
> It is a pipeline indeed, but not the last (doc says: most-recently-executed).
> The last is the 'false' simple command/pipeline.
On Tue, Dec 10, 2024 at 09:28:31AM +0100, Ulrich Müller wrote:
> > On Mon, 09 Dec 2024, Mike Jonkmans wrote:
>
> >> Why is `if false; then :; fi' not a pipeline? It is a command, and the
> >> components of a pipeline are commands.
>
> > It is a pipeline indeed, but not the last
> > (doc says
a simple command is a pipeline
On Tue, Dec 10, 2024, 9:44 AM Andreas Schwab wrote:
> On Dez 10 2024, Mike Jonkmans wrote:
>
> > With 'if false... fi | true' there are two pipelines:
> > 1) false
> > 2) (compound command) if | true
>
> There is only one pipeline, consisting of two commands.
>
> -
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
13 matches
Mail list logo