4 ms·
Prefer `#!/usr/bin/env bash` instead, since /bin/bash isn't a standardized location for bash (even across Linux distros). The former causes $PATH to be searched
by _7tgr 2y ago
Prefer `#!/usr/bin/env bash` instead, since /bin/bash isn't a standardized location for bash (even across Linux distros). The former causes $PATH to be searched for bash.
- n_plus_1_acc 2y agoIs /usr/bin/env a standardized location?
- _7tgr 2y agoI don't know, but it's been more reliable for me than /bin/bash. I think env is part of POSIX.
- ko1nksm 2y agoNo. No new locations added in POSIX.1-2024. https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap10.html https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1... POSIX omits from standardisation what is not necessary for an application to work, so that a wide range of systems can be supported. As for Shebang, it can be rewritten in the installation script and is therefore considered an area of system administration.
- mappu 2y agoThis is pretty common advice but I think it is fighting the previous war. This idea is useful for virtualenv-type tricks if you want to ensure use of your personal version of the interpreter on a shared system, but you have to boil an ocean of scripts. You don't know if you caught them all. Docker won instead - a quick filesystem namespace comprehensively catches everything. Just use #!/bin/bash. EDIT: I was thinking about Linux, but I suppose macOS users are stuck with needing this for Homebrew-supplied bash?
- _7tgr 2y ago#!/bin/bash won't work on, say, nixos, and as you noted, many non-linux platforms. It's a few more characters to do something (more) portable! You're right that docker (or something like nix flakes, which are lighter-weight/easier to introspect imo) are probably a better solution in the long run, though.