Created
November 22, 2016 23:56
-
-
Save cablehead/5c07414b6cd3b13777d7e17fa7ff09a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local levee = require("levee") | |
local _ = levee._ | |
local h = levee.Hub() | |
_.fcntl_nonblock(0); h.stdin = h.io:r(0) | |
_.fcntl_nonblock(1); h.stdout = h.io:w(1) | |
local stream = h.stdin:stream() | |
local count= 0 | |
while true do | |
local err, line = stream:line() | |
if err then break end | |
h.stdout:send(line, "\n") | |
count = count + 1 | |
end | |
h.stdout:send(("count: %s\n"):format(count)) | |
h.stdout.empty:recv() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
imgix:tmp andy$ for i in $(seq 1 3) ; do echo $i; sleep 1; done | levee run io.lua | |
1 | |
2 | |
3 | |
count: 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment