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:
14
lcmd.h
14
lcmd.h
@@ -9,7 +9,17 @@
|
||||
|
||||
#include "lua.h"
|
||||
|
||||
int luaB_command (lua_State *L);
|
||||
int luaB_interactive (lua_State *L);
|
||||
/* Upvalue indices for shell functions on the main chunk.
|
||||
** Index 0 is _ENV (standard). Indices 1-4 are lush shell functions. */
|
||||
#define LUSH_UPVAL_COMMAND 1
|
||||
#define LUSH_UPVAL_INTERACTIVE 2
|
||||
#define LUSH_UPVAL_GETENV 3
|
||||
#define LUSH_UPVAL_SETENV 4
|
||||
#define LUSH_NUM_UPVALS 5 /* total: _ENV(0) + 4 shell functions */
|
||||
|
||||
int lushCmd_command (lua_State *L);
|
||||
int lushCmd_interactive (lua_State *L);
|
||||
int lushCmd_getenv (lua_State *L);
|
||||
int lushCmd_setenv (lua_State *L);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user