lua-users home
lua-l archive

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

On Fri, Nov 6, 2009 at 2:46 PM, Nevin Flanagan <> wrote:
> If you have access to the debug library inside your Lua environment,
> debug.getinfo contains a function that you can use to retrieve information
> like what name the function was called from.

This is true, but the 'function' (or rather, chunk) which is executed
when your script runs is anonymous.

However, the arg table is always available if your code runs as a
script. The caveat is that this applies to the Lua executable itself;
it may not make sense in an embedded environment (but then you could
set a helpful global)

For plain Lua, arg[-1] is the path of the Lua executable, arg[0] is
the script (path included, maybe) and arg[1]...arg[#arg] are the
command-line arguments.

steve d.