help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Not to set PIPESTATUS unless necessary


From: Kerin Millar
Subject: Re: Not to set PIPESTATUS unless necessary
Date: Thu, 09 May 2024 03:22:28 +0100
User-agent: Cyrus-JMAP/3.11.0-alpha0-443-g0dc955c2a-fm-20240507.001-g0dc955c2

On Thu, 9 May 2024, at 2:57 AM, Peng Yu wrote:
> Hi,
>
> true | true
> false
> echo ${PIPESTATUS[@]}
>
> In the above commands, echo will print 1. But such information is also
> available in $?. Therefore, I think it is unnecessary to set
> PIPESTATUS after false. It is better to preserve its value until it is

Bear in mind that "false" is also a foreground pipeline there.

> really necessary. Otherwise, users will have to preserve PIPESTATUS
> after running true | true. This will result in more code to write.

Can you show a realistic program in which it necessitates significantly more 
code?

>
> Is there already a switch to turn on the behavior that I suggested? If
> not, can this feature be added?

There exists no such switch.

-- 
Kerin Millar



reply via email to

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