aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2018-02-20 17:28:59 +0000
committerWarner Losh <imp@FreeBSD.org>2018-02-20 17:28:59 +0000
commita83546e5914f9733631d59202a0d76eb3ca9df61 (patch)
tree52f701690b596537bfba4be923cc795b33a65f92
parent7efedde8536394189b1e3bf0c3959f48d6359f31 (diff)
Notes
-rw-r--r--stand/liblua/lutils.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/stand/liblua/lutils.c b/stand/liblua/lutils.c
index 854ec3fc1962..0c2232bab6f2 100644
--- a/stand/liblua/lutils.c
+++ b/stand/liblua/lutils.c
@@ -34,6 +34,31 @@ __FBSDID("$FreeBSD$");
#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] = (char *)(intptr_t)luaL_checkstring(L, i + 1);
+ argv[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 @@ lua_readfile(lua_State *L)
#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),