Hide shell functions from _G using upvalues on the main chunk
Store __command, __interactive, __getenv, __setenv as upvalues populated by lua_load() from the registry, keeping them invisible to user code while accessible to the parser's codegen.
This commit is contained in:
@@ -155,5 +155,9 @@ void luaopen_builtins (lua_State *L) {
|
||||
lua_setfield(L, -2, "exec");
|
||||
lua_pushcfunction(L, builtin_umask);
|
||||
lua_setfield(L, -2, "umask");
|
||||
lua_setglobal(L, "__builtins");
|
||||
/* Store as __lush.builtins in registry */
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_LUSH);
|
||||
lua_insert(L, -2);
|
||||
lua_setfield(L, -2, "builtins");
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user