[Top][All Lists]

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

Re: pipefail with SIGPIPE/EPIPE

From: Greg Wooledge
Subject: Re: pipefail with SIGPIPE/EPIPE
Date: Fri, 24 Mar 2017 07:57:16 -0400
User-agent: Mutt/

On Thu, Mar 23, 2017 at 10:14:01PM -0700, Pádraig Brady wrote:
> OK let's not derail this into a discussion specific to errexit.
> Can we please improve things?
> You say to not use errexit, and instead use `|| exit 1` where appropriate.
> In that case can we fix this case?
>   set -o pipefail
>   yes | head -n1 || exit 1
>   echo this is skipped

What do you think is broken, here?

imadev:~$ yes | head -n1
imadev:~$ declare -p PIPESTATUS
declare -a PIPESTATUS=([0]="141" [1]="0")

I don't see any problem in bash's behavior.  It's exiting because you
asked it to exit if the pipe failed, and the pipe failed.  The pipe
failed because yes(1) returned a nonzero exit code, and you turned on
the pipefail option.

What exactly are you asking to change?

reply via email to

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