[Top][All Lists]

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

Re: pipefail with SIGPIPE/EPIPE

From: Pádraig Brady
Subject: Re: pipefail with SIGPIPE/EPIPE
Date: Thu, 23 Mar 2017 22:14:01 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 23/03/17 09:34, Greg Wooledge wrote:
> On Thu, Mar 23, 2017 at 08:50:45AM -0700, Pádraig Brady wrote:
>> I was bitten by this again when combined with set -e.
>> I.E. this script doesn't finish:
>> #!/bin/bash
>> set -o errexit
>> set -o pipefail
>> yes | head -n1
>> echo finished
>> That makes the errexit and pipefail options decidedly less useful.
> No.  It makes errexit less useful.  Errexit (a.k.a. set -e) is horrible,
> and you should not be using it in any new shell scripts you write.
> It exists solely for support of legacy scripts.

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


reply via email to

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