[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luaL_loadbuffer API cannot deal with shebang
- From: Jim <djvaios@...>
- Date: Wed, 22 May 2019 22:53:10 +0200
On 5/22/19, Coda Highland <chighland@gmail.com> wrote:
> Option 3:
> if (buffer[0] == '#' && buffer[1] == '!')
> { buffer[0] = '-'; buffer[1] = '-'; }
>
> A shebang is syntactically a comment in shell scripting, so replacing one
> comment syntax with another is a fairly elegant solution IMO. It's an
> extremely cheap check, an extremely cheap patch, and completely safe.
indeed.
i also did that a while ago when i wrote a custom interpreter and totally
forgot about it.
for such cases a C API lua_main() function resembling the "Tcl_Main()"
Tcl C API procedure could be added. a simple interpreter could
then be implemented using this function (if said function does not use
readline, else even the standard interpreter could use it).