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: microsuxxor
Subject: Re: PIPESTATUS differs from $? for compound command
Date: Tue, 10 Dec 2024 04:33:00 +0100

the | true is the.last pipe
while witbout , its.one cmd less
the | true is $pipestatus[1][*]

On Tue, Dec 10, 2024, 4:31 AM Dale R. Worley <worley@alum.mit.edu> wrote:

> 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]