Re:NixOS 18.03 Released
by tathougies on Friday April 06, 2018 @11:25AM
(#16773940)
You shouldn't be using /bin/bash anyway. The proper she-bang is '#!/usr/bin/env bash', which works on nix. The location of bash in /bin/ is actually not standard at all, despite some linux distributions doing that. In particular, the BSDs also do not have bash in /bin. This is why using '/usr/bin/env bash' is more portable
[ Parent
| on HN ]
Re:NixOS 18.03 Released
by eikenberry on Friday April 06, 2018 @01:36PM
(#16775287)
> /usr/bin/env
That won't work everywhere either as the location of 'env' is not a fixed standard either. Eg. In some *nix's its at /bin/env.
What modern/surviving Unix-likes don't have even a symlink in `/usr/bin/env`?
I'm not 100% sure on all of these, but every one of the dozens of Linux distros I've used has `/usr/bin/env`. macOS has it, and it looks like FreeBSD does, too, and so does NetBSD.
Who are the oddballs? Does it include any of the free Unices?
(I'm not trying to be shitty; I'd really like to know. I spent some time Googling about conventions for the `env` command, and examples of incompatible systems. The only ones I found were two old, proprietary Unices. I got tired of searching and was hoping someone who knows a few examples offhand could help me out.)
I've always mechanically written '#!/bin/bash' as my shebang for bash script, while I normally use '#!/usr/bin/env python' for python scripts. In retrospect, that sounds obviously incoherent.
I would like to know if there is some common practice/standard around using '/usr/bin/env' in shebangs.
Could you please elaborate more?
Re:NixOS 18.03 Released
by wereHamster on Friday April 06, 2018 @11:35AM
(#16774020)
But is `/usr/bin/env` standard?
Incidentally, macOS, whose CLI is derived from BSD, does in fact have /bin/bash.
Conversely, Python's PEP394 explicitly discourages `/usr/bin/env python`, so there's that. (I know why the PEP says so, just pointing out that it differs from Nix style)
Re:NixOS 18.03 Released
by adamtulinius on Friday April 06, 2018 @11:48AM
(#16774143)
The PEP doesn't even mention /usr/bin/env. Look for yourself:
https://www.python.org/dev/peps/pep-0394/