summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-14 21:55:43 +0000
committerSteven Barth <steven@midlink.org>2008-08-14 21:55:43 +0000
commit2b0e8c6d7fc72c5c4d090dd3311c341f280e2237 (patch)
tree752f0065a0f8d354c858a2107ccc47043b16517b
parent23a4d764d939552e0bf5b22d9262d7ad005f1aa9 (diff)
libs/core: Add luci.execi as memory efficient replacement for now deprecated luci.execl
-rw-r--r--libs/core/luasrc/util.lua19
1 files changed, 17 insertions, 2 deletions
diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua
index 638bb056a7..51d66e08e5 100644
--- a/libs/core/luasrc/util.lua
+++ b/libs/core/luasrc/util.lua
@@ -594,9 +594,24 @@ function exec(command)
return data
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
--- @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)
local pp = io.popen(command)
local line = ""