Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> pipefail when nothing is being piped (pipefail is not a "fix" it is an option

I think it’s pretty good hygiene to set pipefail in the beginning of every script, even if you end up not using any pipes. And at that point is it that important to go back and remove it only to then have to remember that you removed it once you add a pipe?



Pipefail is not a fix. It is an option. It makes sense sometimes, it does not make sense other times. When you are using a pipeline in a script where you care about error handling then you should be asking yourself exactly what kind of error handling semantics you expect the pipeline to have and set pipefail accordingly.

Sometimes you should even be using PIPESTATUS instead.


It’s an option and one that should probably have been on by default together with -e.

It’s not so much about error handling. It’s more about not executing all sorts of stuff after something fails.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: