summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-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 638bb056a..51d66e08e 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 = ""