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



On Mon, 2006-01-30 at 13:05 -0500, Tom Metro wrote:
> Ed Hill wrote:
> > ...its a good idea to develop the
> > habit of using "#!/usr/bin/env INTERPRETER_NAME" since 1) its maximally
> > portable and 2) it allows for easy run-time selection of different
> > installed versions.
> 
> I hadn't heard of that. Can you elaborate on how it accomplishes 1 and 
> 2? Is it through magic built-in to exec(), because I don't see anything 
> in the env(1) man page to suggests the enhancements you list.

By executing the script using "/usr/bin/env INTERPRETER", it will choose
the first instance of INTERPRETER that it finds in your PATH.  So, for
instance, if multiple versions of php are installed in:

  /usr/bin/php
  /usr/local/bin/php

then you can select which one you want:

  $ export PATH=/usr/bin:/usr/local/bin
  $ which php
  /usr/bin/php

and:

  $ export PATH=/usr/local/bin:/usr/bin
  $ which php
  /usr/local/bin/php

The portability is just a fact.  Its not portable to every machine on
the planet but it will run on a very large fraction of Unix and Linux
machines.

Ed

-- 
Edward H. Hill III, PhD
office:  MIT Dept. of EAPS;  Rm 54-1424;  77 Massachusetts Ave.
             Cambridge, MA 02139-4307
emails:  eh3 at mit.edu                ed at eh3.com
URLs:    http://web.mit.edu/eh3/    http://eh3.com/
phone:   617-253-0098
fax:     617-253-4464





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