lua-users home
lua-l archive

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


I'm using debug.getinfo( aLevel, 'S' ).source to discover where a given piece of code has been loaded from so as to locate resources relative to the source code location.

This works rather nicely when modules are loaded from individual files through 'require'.

Unfortunately, when aggregating multiple modules into one luac file and accessing that file with an explicit path, debug.getinfo doesn't include any path information.

For example, assuming 'all-in-one.luac' is a luac aggregation of several modules, the following invocation will not return any path information:

% lua /path/to/all-in-one.luac

In such scenario, debug.getinfo will return something like '@Module' as the source even though the source was loaded from 'all-in-one.luac' as specified in _G.arg[ 0 ].

In such case, shouldn't debug.getinfo reflect the path specified in _G.arg[ 0 ] instead of defaulting to the module name as a source, e.g.: shouldn't it return '@/path/to/all-in-one.luac' instead of '@Module'?

Or am I missing something altogether?

FWIW, here is the code used to derive a source location (note the debug.getinfo path):

Thanks in advance for any insights.