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:
Cormac Shannon
2026-03-12 22:46:56 +00:00
parent 34bfabccbd
commit f88b17959f
8 changed files with 134 additions and 77 deletions

3
lua.h
View File

@@ -83,7 +83,8 @@ typedef struct lua_State lua_State;
/* index 1 is reserved for the reference mechanism */
#define LUA_RIDX_GLOBALS 2
#define LUA_RIDX_MAINTHREAD 3
#define LUA_RIDX_LAST 3
#define LUA_RIDX_LUSH 4
#define LUA_RIDX_LAST LUA_RIDX_LUSH
/* type of numbers in Lua */