lua-users home
lua-l archive

Re: Can a Lua module find out whether it is being required or dofiled?

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


Am 23.09.2015 um 16:04 schrieb Luiz Henrique de Figueiredo:
 - require will pass the module name to the file chunk as argument
Since Lua 5.2, require also passes the path to the file:
% cat m.lua
print("args",...)
% lua -lm /dev/null
args	m	./m.lua
% lua m.lua
args
c.\lua> lua53.exe m.lua m.lua z:\universe
args m-lua z:\universe
Unfortunatly "..." becomes filled with values equal arg[1]..arg[n]

AltStyle によって変換されたページ (->オリジナル) /