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

I disagree. set -eu should be at the top of every bash script.

This is the classic braceless if-guard mistake; leave it out today because you don't need it, forget, add something tomorrow and it breaks.



You can over-rely on "set -e" however:

  #!/usr/bin/env bash
  set -e
  fail() { false ; echo hello; }
  if ! fail; then :; fi
That outputs "hello" and exits with 0.




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

Search: