diff --git a/lsyncd.c b/lsyncd.c index 990aeac..cffddb8 100644 --- a/lsyncd.c +++ b/lsyncd.c @@ -804,6 +804,31 @@ l_exec(lua_State *L) /* pipe file descriptors */ int pipefd[2]; + /* expands tables if there are any */ + { + int i; + for(i = 1; i <= lua_gettop(L); i++) { + if (lua_istable(L, i)) { + int tlen; + int it; + /* table is now on top of stack */ + lua_checkstack(L, lua_gettop(L) + lua_objlen(L, i) + 1); + lua_pushvalue(L, i); + lua_remove(L, i); + argc--; + tlen = lua_objlen(L, -1); + for (it = 1; it <= tlen; it++) { + lua_pushinteger(L, it); + lua_gettable(L, -2); + lua_insert(L,i); + i++; + argc++; + } + i--; + lua_pop(L, 1); + } + } + } /* writes a log message, prepares the message only if actually needed. */ if (check_logcat("Exec") >= settings.log_level) { int i; diff --git a/lsyncd.lua b/lsyncd.lua index da24a18..8791974 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -2728,6 +2728,9 @@ function spawn(agent, binary, ...) if lsyncdStatus == "fade" then log("Normal", "ignored spawn processs since status fading") end + if type(binary) ~= "string" then + error("calling spawn(agent, binary, ...), binary is not a string", 2) + end local pid = lsyncd.exec(binary, ...) if pid and pid > 0 then local sync = InletFactory.getSync(agent)