/usr/bin/env

Craig Sanders cas at taz.net.au
Fri Dec 23 02:14:55 AEDT 2016


On Fri, Dec 23, 2016 at 01:37:11AM +1100, Craig Sanders wrote:
> one of the worst problems with doing it is that it breaks the ability
> to pass command-line options to the interpreter in the #! line - e.g.
> '#!/bin/bash -e' works, but with '#!/usr/bin/env bash -e' the '-e' is
> ignored by bash.

that's not quite true. it's not that bash ignores the '-e', it's that
env tries to run a non-existent program called 'bash -e'

e.g.

$ cat foo.bash
#!/usr/bin/env bash -e

echo foo

$ ./foo.bash
/usr/bin/env: ‘bash -e’: No such file or directory


IMO, that's an unmistakable signal that env was not intended to be used
in this way.



IIRC some versions of env (not the one in GNU coreutils, which is
installed on almost every linux system - with some embedded or
busybox/tinybox systems being the exceptions) will still run the correct
interpreter but fails to pass on any options.

craig

--
craig sanders <cas at taz.net.au>


More information about the luv-main mailing list