3 ms·
> Why not make all your shell scripts #!/bin/bash Because it's not always installed there. See, for example, FreeBSD where bash typically lives in /usr/local/b
by chungy 4y ago
> Why not make all your shell scripts #!/bin/bash
Because it's not always installed there. See, for example, FreeBSD where bash typically lives in /usr/local/bin/bash. Or in the Linux world, Nix and Guix.
Use "#!/usr/bin/env bash" to account for all these possibilities.
- Ferret7446 4y agoIf we're going to be pedantic, env doesn't have to be installed at /usr/bin/env either. See https://www.felesatra.moe/blog/2021/07/03/portable-bash-shebang https://www.felesatra.moe/blog/2021/07/03/portable-bash-sheb...
- tpoacher 4y agoi cant remember where I saw it now, or what the main argument was, but I remember reading a rather authoritative article recommending against the env approach, and recommending people stick to #!/bin/bash regardless of the above, otherwise valid point. Dunno if anyone here with a better memory remembers the article to link here ...
- asicsp 4y agoPerhaps these? * https://unix.stackexchange.com/a/29620 https://unix.stackexchange.com/a/29620 * https://stackoverflow.com/q/21612980 https://stackoverflow.com/q/21612980