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

cheers,
Pádraig

Reply via email to