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

I agree. You must fail fast.

My best shell advice is to put these commands at the beginning of every script:

    set -e # stop scripts on errors
    set -u # stop script if undefined var
    set -o pipefail # stop script if there's a pipe failure 
Use them to have a saner life.


And you can compact them to

    set -euo pipefail


For most uses, I consider all of these unwanted at best and potential disasters at worst. If you use them, make sure you understand exactly what each of these do. If you just follow a dictum you found on HN blindly and just copy-paste them, you're in for a world of hurt.

Example for set -e: https://mywiki.wooledge.org/BashFAQ/105


My favourite set of pragmas:

  set -o errexit -o noclobber -o nounset -o pipefail
  shopt -s failglob inherit_errexit
These are all easy to find in the Bash manual.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: