On Fri, Dec 23, 2016 at 12:57:48AM +1100, Andrew McGlashan wrote:
> #!/usr/bin/env bash

please don't promote thet obnoxious brain-damage. it's bad enough seeing the
#!/usr/bin/env disease on sites like stackexchange (where at least they have
the excuse of catering to non-linux systems - and even there it's broken,
because env isn't guaranteed to be in /usr/bin on all systems anyway) but bash
will be /bin/bash on every linux system that exists, and always will be.

there are lots of good reasons why abusing /usr/bin/env like this is a bad
idea at:

http://unix.stackexchange.com/questions/29608/why-is-it-better-to-use-usr-bin-env-name-instead-of-path-to-name-as-my

(see also the Linked and Related Q&As on the RHS of the page)

the one argument in favour of doing this (that the script will be run by the
first matching interpreter found in the PATH) is both a blessing and a curse.
at best it's a minor convenience. at worst, it's a potential security risk -
it's not an accident or an oversight that every unix system since the #! line
was invented DOESN'T search $PATH for the interpreter.


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.

this is bad enough for bash, but worse for other scripting languages where
passing command-line options to the #! interpreter is routine (like sed,
awk, perl) or required (like make, which requires '-f' on the #! line of an
executable make script).

also, env messes with ARGV[0] which can make the script difficult or
impossible to find with ps


'#!/usr/bin/env interpreter' - brought to you by the people who think
that 'curl http://randomwebsite/path/to/script | sudo bash' is a good
way to install software.

craig

--
craig sanders <c...@taz.net.au>
_______________________________________________
luv-main mailing list
luv-main@luv.asn.au
https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main

Reply via email to