libs/core: Add luci.execi as memory efficient replacement for now deprecated luci.execl

This commit is contained in:
Steven Barth 2008-08-14 21:55:43 +00:00
parent 23a4d764d9
commit 2b0e8c6d7f

View file

@ -594,9 +594,24 @@ function exec(command)
return data return data
end end
--- Execute given commandline and gather stdout. --- Return a line-buffered iterator over the output of given command.
-- @param command String containing the command to execute -- @param command String containing the command to execute
-- @return Table containing the command's stdout splitted up in lines -- @return Iterator
function execi(command)
local pp = io.popen(command)
return pp and function()
local line = pp:read()
if not line then
pp:close()
end
return line
end
end
-- Deprecated
function execl(command) function execl(command)
local pp = io.popen(command) local pp = io.popen(command)
local line = "" local line = ""