Index: stand/common/interp_lua.c =================================================================== --- stand/common/interp_lua.c +++ stand/common/interp_lua.c @@ -139,7 +139,8 @@ if ((status = luaL_dostring(luap, line)) != 0) { /* * If we could not parse the line as Lua syntax, - * try parsing it as a loader command. + * try to see if there is a Lua override first, + * otherwise call the builtin interpreter command. */ lua_pop(luap, 1); if (parse(&argc, &argv, line) == 0) { Index: stand/liblua/lutils.c =================================================================== --- stand/liblua/lutils.c +++ stand/liblua/lutils.c @@ -34,6 +34,31 @@ #include "lutils.h" #include "bootstrap.h" +/* + * Like loader.perform, except args are passed already parsed + * on the stack. + */ +static int +lua_command(lua_State *L) +{ + int i; + int res = 1; + int argc = lua_gettop(L); + char **argv; + + argv = malloc(sizeof(char *) * (argc + 1)); + if (argv == NULL) + return 0; + for (i = 0; i < argc; i++) + argv[i] = luaL_checkstring(L, i + 1); + argc[argc] = NULL; + res = interp_builtin_cmd(argc, argv); + free(argv); + lua_pushinteger(L, res); + + return 1; +} + static int lua_perform(lua_State *L) { @@ -213,6 +238,7 @@ #define REG_SIMPLE(n) { #n, lua_ ## n } static const struct luaL_Reg loaderlib[] = { REG_SIMPLE(delay), + REG_SIMPLE(command), REG_SIMPLE(getenv), REG_SIMPLE(perform), REG_SIMPLE(printc),