lua-users home
lua-l archive

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


Peter Hill wrote:
> For Lua on a unix system, a file with the "x" flag set should start with a
> "#! /bin/lua" line (whether the file is Lua text or Lua byte code)
> followed by the actual file. The Lua interpreter will be piped the data
> after the "#!" line (which it won't see).

Daniel Silverstone:
> What fairy wonderland do you live in?

Perth, Australia! :-)   [Photos of faries provided upon request]


> the 'shebang' as it is often referred to indicates to the kernel (or
> shell, or whatever feels like parsing it) what program to run (and what
> args to give it) to get it to parse the program in question...

Ie, it denotes that the rest of the file is an 'executable' suitable for
handling by the program mentioned in the 'shebang'.


> It *is* up to the parser (Lua, shell, whatever) to parse out the shebang
> so Lua does handle it in its parser.

You seem to have missed my point. The 'shebang' is a feature of a specific
_Operating System_... NOT of Lua.

It's sloppiness of the part of an operating system to put such data 'in
band' (Windows handles it by giving the file and extension, eg ".lua", and
mapping ".lua -> C:\Program Files\Lua\WinLua.exe"), and recognising it is
not something that should occur as high up as the Lua syntax (which can be
sourced from a variety of places & systems). Ie, the Lua Parser should NEVER
see it at all. Rather, it should be handled lower down in base routines that
are closer to the operating system.


> However when it comes to compiled chunks, they're a big lump of binary
> goo, and as such, what you have to do is persuade the kernel how to handle
> them.

It is my understanding of shells (correct me if I'm wrong) that putting a
'shebang' at the front of a file causes the shell to execute the 'shebang'
program with the *remainder* of the file piped as standard input. Thus,
appending a 'shebang' to the front of a Lua byte-code file should work just
fine if it is just run from the shell prompt. Of course Lua code loaders
like 'loadstring' etc used on the contents of the file would not work unless
they understood the 'shebang' but that is a different issue.


> As for getting Lua to do clever things based on 'x' attributes etc, that
> would break Lua's spirit of working entirely in the ANSI standard wherever
> possible.

The core of Lua works in the ANSI standard. By necessity, porting Lua to
different Operating Systems may require that some low-level routines use
non-ANSI Operating System specific system calls (some systems where Lua runs
are, after all, very esoteric). I did not say that an implementer *must*
recognise the 'x' flag... that is their choice (they might simply use the
'shebang' to identify the file). What I'm doing is giving people the
*option* to do so by encapsulating the 'typing' of Lua executables in low
level routines.


> The way Lua does things now is (at least in my opinion) __right__ and
> shouldn't be changed to make it rely on system knowledge at all.

Rob Kendrick:
> It already does rely on system knowledge.  (The ignoring of #! lines in
> text lumps.)

You said it all!

The core of Lua should not rely on any operating system stuff, and Shebangs
are just that! Not all Operating Systems use them and unless Lua is compiled
for such a system it *should* have such OS-specific code commented out!

*cheers*
Peter Hill.