Re: pipefail with SIGPIPE/EPIPE

2017-03-25 Thread Chet Ramey
On 3/24/17 7:57 AM, Greg Wooledge wrote: > 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

Re: pipefail with SIGPIPE/EPIPE

2017-03-25 Thread Chet Ramey
On 3/23/17 3:27 PM, Jay Freeman (saurik) wrote: > (Potentially of mild interest is this thread on Hacker News from earlier > today, where multiple people are suggesting the usage of "set -e" along with > "set -u" and "set -o pipefile".) > > https://news.ycombinator.com/item?id=13940322 It's

Re: pipefail with SIGPIPE/EPIPE

2017-03-24 Thread Pádraig Brady
On 24/03/17 04:57, Greg Wooledge wrote: > 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

Re: pipefail with SIGPIPE/EPIPE

2017-03-24 Thread Greg Wooledge
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

Re: pipefail with SIGPIPE/EPIPE

2017-03-23 Thread Pádraig Brady
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

Re: pipefail with SIGPIPE/EPIPE

2017-03-23 Thread Jay Freeman (saurik)
> 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. Wow. For those of us who don't know this, what should we be using instead? Is using a trap on ERR any better? Is your suggestion that ||

Re: pipefail with SIGPIPE/EPIPE

2017-03-23 Thread Greg Wooledge
On Thu, Mar 23, 2017 at 07:27:19PM +, Jay Freeman (saurik) wrote: > > 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. > > Wow. For those of us who don't know this, what should we be

Re: pipefail with SIGPIPE/EPIPE

2017-03-23 Thread Greg Wooledge
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

Re: pipefail with SIGPIPE/EPIPE

2017-03-23 Thread Pádraig Brady
On 15/02/15 14:14, Pádraig Brady wrote: > On 15/02/15 21:59, Daniel Colascione wrote: >> On 02/15/2015 01:48 PM, Chet Ramey wrote: >>> On 2/13/15 12:19 PM, Pádraig Brady wrote: I was expecting bash to handle SIGPIPE specially here, as in this context it's informational rather than an

Re: pipefail with SIGPIPE/EPIPE

2015-02-15 Thread Chet Ramey
On 2/13/15 12:19 PM, Pádraig Brady wrote: I was expecting bash to handle SIGPIPE specially here, as in this context it's informational rather than an indication of error. I don't agree. It's a fatal signal whose default disposition is to terminate a process, which is exactly what happens in

Re: pipefail with SIGPIPE/EPIPE

2015-02-15 Thread Daniel Colascione
On 02/15/2015 01:48 PM, Chet Ramey wrote: On 2/13/15 12:19 PM, Pádraig Brady wrote: I was expecting bash to handle SIGPIPE specially here, as in this context it's informational rather than an indication of error. I don't agree. It's a fatal signal whose default disposition is to terminate

Re: pipefail with SIGPIPE/EPIPE

2015-02-15 Thread Pádraig Brady
On 15/02/15 21:59, Daniel Colascione wrote: On 02/15/2015 01:48 PM, Chet Ramey wrote: On 2/13/15 12:19 PM, Pádraig Brady wrote: I was expecting bash to handle SIGPIPE specially here, as in this context it's informational rather than an indication of error. I don't agree. It's a fatal signal