Re: env (GNU coreutils) 5.93 patch

[email protected] (Bob Proulx) Fri, 30 Dec 2005 22:56:43 -0700
Newsgroups gmane.comp.gnu.core-utils.bugs,gmane.comp.gnu.sh-utils.bugs
Message-ID <[email protected]>
Shigeru Makino wrote:
> For example =E2=80=9Cbash=E2=80=9D is in if you don=E2=80=99t know or d=
ifference path.
> You can write follows script:
> #! /usr/bin/env bash

Yes, that is very useful for bash.  Also for perl, ruby, python too.
Because none of those are standard commands.  They are not defined by
a standard and so may not be installed in a system bin directory.
They might only be available as an add-on.  A user might have them
installed in /usr/local or even in their $HOME directory.  Therefore
using "#!/usr/bin/env command" allows command to be found on PATH,
something that #! by itself can't do.  Finding commands on PATH is
very useful and allows a script to work on systems with those
non-standard commands installed in different places without editing a
hard coded path in the calling script.

> but I try to same technique for awk script, and get err !
> #! /usr/bin/env awk -f

But awk is different because the awk command is a standard command.
It is defined by POSIX.  Therefore /usr/bin/awk is at least as well
defined and as portable as /usr/bin/env.  So with awk you don't need
to use the "/usr/bin/env awk" trick to find it on path.

Bob