|
|
|
|
|
by vog
3377 days ago
|
|
Bash is not always /bin/bash. On some systems (BSDs) it is /usr/bin/bash. So the portable sh'bang line for bash is: #!/usr/bin/env bash
And there you can't add "-eu" anymore, because only one argument is possible in sh'bang lines. (/usr/bin/env would try to find an executable named "bash -eu")So #!/usr/bin/env bash
set -eu
is the more portable approach. However, for "/bin/sh" this should work portably: #!/bin/sh -eu
|
|
Nitpick: on every BSD system I've used, it's /usr/local/bin/bash. But I definitely agree that using /usr/bin/env bash is the preferred solution for when you want to use bash (although I don't think it's even installed by default on most BSD's); as an Arch user (where /usr/bin/python is symlinked to python3 rather than python2), I appreciate those who go out of their way to use proper, portable shebangs.