mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-12-13 14:43:09 +00:00
allow tables as arguments to spawn/exec, so e.g. rsyncOpts can include several options
This commit is contained in:
parent
926033a7d3
commit
07e35ffe60
25
lsyncd.c
25
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;
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user