X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/7e6f1336f26e8c36a1768ae1f7f076a30030a8a8..36767762270a9ec0f510e4573e0b40f77597aa32:/helpers.lua diff --git a/helpers.lua b/helpers.lua index b681cb0..6c0c3c4 100644 --- a/helpers.lua +++ b/helpers.lua @@ -106,7 +106,7 @@ end -- {{{ Pipe operations --- read the full output of a pipe (command) +-- read the full output of a command output function helpers.read_pipe(cmd) local f = assert(io.popen(cmd)) local output = f:read("*all") @@ -114,6 +114,16 @@ function helpers.read_pipe(cmd) return output end +-- return line iterator of a command output +function helpers.pipelines(...) + local f = assert(io.popen(...)) + return function () -- iterator + local data = f:read() + if data == nil then f:close() end + return data + end +end + -- }}} -- {{{ A map utility @@ -149,4 +159,5 @@ function helpers.spairs(t) end --}}} + return helpers