[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: require() relative to calling file
- From: Martin <eden_martin_fuhrspam@...>
- Date: Sat, 4 Feb 2017 04:02:52 -0800
Just want to note that debug.getinfo() could return source file for
current function. I think this is more correct approach than working
with arg[] as not all code is loaded from shell.
You may try to saving this code to separate file and call it from other
directory.
--[ test_path.lua ]--
local print_info =
function()
local level = 0
while true do
local info = debug.getinfo(level, 'S')
if not info then
break
end
print(('%2d [%s]'):format(level, info.source))
level = level + 1
end
end
print_info()
--[]--
(debug.getinfo(level) returns table with information about function
<level>s up.)