Hacker News new | ask | show | jobs
by ArchD 4172 days ago
I use the shebang "#!/bin/bash -e".

To get the same effect as the "set -o errexit -o nounset", I think you can use "#!/bin/bash -e -u". (There seems to be no option for pipefail.)

2 comments

The "shebang" treats everything after the binary as a single argument. It only does one argument from the shebang and the file itself as the final argument. So it would run that kinda like

    bash '-e -u' $file
But you can do

    #!/bin/bash -eu
This breaks if your script is sourced by another shell. Best use 'set -eu' at the start instead.