lua-users home
lua-l archive

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


The standard dofile executes the lua chunk in the global environment.
I think it should be in the environment of the caller of dofile.
See the following:

local std_loadfile=loadfile

function dofile(filename)
  local func=assert(std_loadfile(filename))
  setfenv(func,getfenv(2))
  func()
end