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: Phi Debian
Subject: Re: PIPESTATUS differs from $? for compound command
Date: Tue, 10 Dec 2024 11:22:09 +0100

On Tue, Dec 10, 2024 at 10:42 AM Mike Jonkmans <bashbug@jonkmans.nl> 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 commands.
> >
> > > It is a pipeline indeed, but not the last
> > > (doc says: most-recently-executed).
> > > The last is the 'false' simple command/pipeline.
> >
> 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
>
>
You may also add this one in your serie :-)
$ [ ! : ] && echo foo
$ echo "ret = $?, status = ${PIPESTATUS[*]}"
ret = 1, status = 1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]