What is the best way to remove or omit a Lua standard library package? For example remove the os library functions in a particular environment. The project in question is
Let's say you only want to open the base and package libraries. In Lua 5.2, the most concise way is
base
package
luaL_requiref(L, "_G", luaopen_base, 1); luaL_requiref(L, "package", luaopen_package, 1); lua_pop(L, 2);
This is how the luaL_openlibs function in linit.c works, except that it loads everything.
linit.c