Subject: Re: Why /usr/bin/env in scripts

From: David Greaves <[email-masked]>
Date: Mon, 25 Apr 2005 10:42:45 +0100

Philip Pokorny wrote:
> I notice that the first line of the pasky shell scripts is
> 
> #!/usr/bin/env bash

> So what am I missing?  Is this a portability aid?
man env:

The first remaining argument specifies the program name to invoke;
it is searched for according to the `PATH' environment variable.  Any
remaining arguments are passed as arguments to that program.

It's a trick to do a PATH search for a script interpreter rather than 
hard coding the path.
Now all we have to do is make sure every distro on the planet has 
/usr/bin/env - and they do.

David