Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

#!/usr/bin/env



Ed Hill wrote:
> By executing the script using "/usr/bin/env INTERPRETER", it will choose
> the first instance of INTERPRETER that it finds in your PATH.

OK, so env(1) isn't directly providing any functionality here, other 
than providing a convenient way of calling execlp(3) (search the path 
for the executable and run it) as a side effect, and working around the 
limitation that:

#!INTERPRETER

(with no path) won't work on most platforms.


> So, for instance, if multiple versions of php are installed...
> then you can select which one you want:

I could see pros and cons to this. Updating bang paths is a pain, and 
usually minimized through symlinks. Depending on the search path could 
lead to surprises. If you happen have some version specific scripts 
dependent on /usr/bin/INTERPRETER and an admin installs an incompatible 
version in /usr/local/bin/INTERPRETER that happens to be first in your 
path, your scripts break. Once you discover the problem, you can of 
course adjust for it by changing your path or modifying the bangpath on 
those version specific scripts.


> The portability is just a fact.

What I wanted to know was what makes it portable. Apparently it is due 
to env(1) being ubiquitous and consistently having that path searching 
side effect in the various implementations.

  -Tom

-- 
Tom Metro
Venture Logic, Newton, MA, USA
"Enterprise solutions through open source."
Professional Profile: http://tmetro.venturelogic.com/




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org