3 ms·
I thought the path was fixed by POSIX but I suppose it's only fixed by convention. Its availability is definitely part of POSIX, though: https://pubs.opengroup.
by pxc 3y ago
I thought the path was fixed by POSIX but I suppose it's only fixed by convention. Its availability is definitely part of POSIX, though: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/env.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/e...
And one of its main uses in practice today is to perform lookup via PATH in shebangs, since it has to do that kind of lookup to be able to launch programs with modified environments as given in those examples anyhow. It obviously can't perform that common function if applications using it can't find it, so it's in an exceptional position relative to other utilities.
NixOS just makes the correct tradeoff here for `env` to be able to perform one of its main functions by putting it in a conventional location.
> Since shebangs have no native way to look up binaries from your PATH scripts should be including the full path to the binary from /nix in the shebang (and they should stop opening PRs asking people to switch to /usr/bin/env for them)
Nixpkgs already has facilities to handle this for scripts that are packaged via Nix. Those shebangs matter only when (a) some impurity is actually desired or (b) the scripts are used/managed out-of-band.
The issue also doesn't only affect NixOS.
> It almost always exists in both /bin/bash and /usr/bin/bash via a symlink.
What if I don't want to use the system bash (ever) because it's old? If someone isn't shipping their own bash or targeting a specific version that they know comes with a target platform very deliberately, why should they point to the system bash?
- charcircuit 3y ago>NixOS just makes the correct tradeoff here for `env` to be able to perform one of its main functions by putting it in a conventional location. At that point you might as well do the same for sh and bash as it would also save a lot of unnecessary headache. Shebangs are not a necessary part of a distro. You can always call the interpreter directly and pass in the script. I personally find the idea of disrupting the normal FHS for purity to be a cool idea, but if you are going to ignore that goal and compromise to increase compatibility with existing scripts I feel you might as well compromise that purity more to support bash as that will solve the users of the OS even more problems. >What if I don't want to use the system bash (ever) because it's old? When you are sharing a bash script with others you typically aren't going to want to use bleeding edge features. I don't see that as a big problem. For your own scripts you can always use the full path to whatever version you want.