On Jul 25, 2004, at 1:57 AM, Jarkko Hietaniemi wrote:

Which is not really portable with command line options, due to how
env(1) works on OS X:

$ <test
#!/usr/bin/env perl -wl
print "hello world"

$ ./test
env: perl -wl: No such file or directory

That is both against the documentation (env(1)) and the UNIX spec,
so I think a bug report to Apple is in order. (Actually, env as such
seems to be working okay, so it is more likely a bug in the #! processing.)

This is one of those historical worts. See "man execve":

     An interpreter file begins with a line of the form:

           #! interpreter [arg]

When an interpreter file is execve()'d, the system execve()'s runs the
specified interpreter. If the optional arg is specified, it becomes the
first argument to the interpreter, and the name of the originally
execve()'d file becomes the second argument; otherwise, the name of the
originally execve()'d file becomes the first argument. The original
arguments are shifted over to become the subsequent arguments. The
zeroth argument, normally the name of the execve()'d file, is left
unchanged.


Thus:

        #!/usr/bin/env perl -wl

is interpreted as:

        /usr/bin/env "perl -wl" scriptname

thus, the error message.
------------------------------------------------------------------------ --
Edward Moy
Apple Computer, Inc.
[EMAIL PROTECTED]


(This message is from me as a reader of this list, and not a statement
from Apple.)



Reply via email to