#! /usr/bin/env considered harmful - Programming On Unix
Users browsing this thread: 3 Guest(s)
|
|||
(14-09-2016, 08:59 PM)pranomostro Wrote: > Not the right interpreter is found Some path are standardized by POSIX, like /bin/sh. env(1) location is not defined by POSIX. All it does is that it will run the 'utility' using the current environment, which is supposed to has the $PATH variable set correctly. One could technically just implement the shebang to search 'utility' in the PATH, which would allow things as "#!sh". (14-09-2016, 08:59 PM)pranomostro Wrote: > No dependencies or modules I'm not especially smarter than you are, but as far as I understand this point, it present corner cases where the same 'utility' appear multiple times in the PATH, at multiple locations. That's the same as you 3rd point. (14-09-2016, 08:59 PM)pranomostro Wrote: > no flags This is, again, implementation specific. And while it MIGHT be the case, it has never been actually experienced (see http://www.in-ulm.de/~mascheck/various/shebang/). What's true though, is that the shebang line is limited, and this limitation is (again!) implementation specific. I've personally been using "#!/bin/sed -f" or "#!/bin/sh -ex" happily for quite some times now. (14-09-2016, 08:59 PM)pranomostro Wrote: > wrong configuration of $PATH The exact problem mentionned is "The fifth and worst problem is that your script is at the mercy of the user’s environment configuration.". THAT IS THE FUCKING POINT OF THE env(1) UTILITY! Of course it will use the environment of the user BECAUSE THAT'S FUCKING WHAT YOU'RE ASKING FOR. "#!/usr/bin/env bash" means "run 'bash' within the current environment. So it's freaking stupid to discuss this point as it would be like complaining about planes not touching the ground all the time. Regarding this whole topic, the shebang is a nifty feature provided by some kernels to hack around the fact that some executables are NOT executable by a machine. You shouldn't expect much about it, but you can have enough confidence in it to use it (It's kind of like relying on bash(1) to be installed everywhere in the end). By nature, the shebang is not portable, for the simple reason that it's not standardized: http://pubs.opengroup.org/onlinepubs/969...hap02.html Wrote:If the first line of a file of shell commands starts with the characters "#!", the results are unspecified. |
|||
Messages In This Thread |
#! /usr/bin/env considered harmful - by jkl - 14-09-2016, 12:27 PM
RE: #! /usr/bin/env considered harmful - by venam - 14-09-2016, 01:04 PM
RE: #! /usr/bin/env considered harmful - by z3bra - 14-09-2016, 01:36 PM
RE: #! /usr/bin/env considered harmful - by josuah - 14-09-2016, 05:34 PM
RE: #! /usr/bin/env considered harmful - by robotchaos - 14-09-2016, 05:35 PM
RE: #! /usr/bin/env considered harmful - by jkl - 14-09-2016, 08:13 PM
RE: #! /usr/bin/env considered harmful - by pranomostro - 14-09-2016, 08:59 PM
RE: #! /usr/bin/env considered harmful - by robotchaos - 14-09-2016, 11:27 PM
RE: #! /usr/bin/env considered harmful - by z3bra - 15-09-2016, 05:40 AM
RE: #! /usr/bin/env considered harmful - by TheAnachron - 15-09-2016, 06:18 AM
RE: #! /usr/bin/env considered harmful - by z3bra - 15-09-2016, 09:14 AM
RE: #! /usr/bin/env considered harmful - by Halfwit - 14-10-2016, 11:51 PM
|