29 lines
1.1 KiB
Markdown
29 lines
1.1 KiB
Markdown
# SHEBANG: The case for `/usr/bin/env bash`
|
|
|
|
Not every system has binaries in the same location!
|
|
|
|
From [Ycombinator](https://news.ycombinator.com/item?id=7596191)
|
|
|
|
|
|
>clarry 708 days ago
|
|
>
|
|
>*Are there any situations where you wouldnt be able to find bash in /bin/bash?*
|
|
>
|
|
>Yes there are.
|
|
>
|
|
>OpenBSD for instance installs third party software under `/usr/local`. Bash is not a part of the base system.
|
|
>
|
|
>env(1) on the other hand is a POSIX standard utility and comes with the OS.
|
|
|
|
> kirubakaran 708 days ago
|
|
>
|
|
> [in addition to what clarry said] Habit of using `/usr/bin/env` becomes more important in other use-cases, such as invoking Python interpreter.
|
|
|
|
>nnnnni 708 days ago
|
|
>
|
|
>Exactly. I often use `#!/usr/bin/env` python2 to specify python 2.x on my systems where python 3 is the default.
|
|
|
|
## Reference
|
|
* [Hey Kid, I'ma Interpreter!! Stop all the static interpreter referencin'!](https://deftly.net/posts/2014-03-17-stop-all-the-ref.html)
|
|
* [Howto Make Script More Portable With #!/usr/bin/env As a Shebang](http://www.cyberciti.biz/tips/finding-bash-perl-python-portably-using-env.html)
|
|
* [Rethinking Your shebang](http://www.brianstorti.com/rethinking-your-shebang/) |