lua-users home
lua-l archive

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


On Tue, Oct 15, 2013 at 12:18:35AM -0400, Rena wrote:
> On Tue, Oct 15, 2013 at 12:07 AM, Benjamin Heath benjamin.joel.heath@gmail.com> wrote:
> > Give it a try and learn for yourself, yo.
> > On Oct 14, 2013 9:04 PM, "Rena" <hyperhacker@gmail.com> wrote:
<snip>
> >> OK, but what's the purpose of 'env'? Can you not write #!lua?
> >>
> Interesting, I thought I'd seen that done before. I wonder why that doesn't
> work?
> 

Because the shebang (#!) is usually processed directly by the kernel, and
the kernel usually won't parse and process the PATH environment variable to
search for a command. It rightfully leaves that job up to userspace. It just
splits the line on whitespace, only processing the first few whitespace
delimited words, and treating the first word as a filename to open and
execute. The limits on line length and number of words varies. Typically you
assume only two words will be parsed, the filename and one argument.

Interestingly, on OS X if you execute the script from the shell it will
apparently parse the shebang and search your PATH to derive a qualified path
for the shebang interpreter. But if you force the C syscall (by e.g. using
the exec command) you get the same error as on other unices, such as Linux
or OpenBSD.