From 517d579bb9f8133871cb24909805d8e27e676638 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Wed, 9 Jan 2019 14:09:57 +1100 Subject: [PATCH] made io create a default sink fd --- module/io.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/module/io.lua b/module/io.lua index daa6ea1..78d7a61 100644 --- a/module/io.lua +++ b/module/io.lua @@ -3,7 +3,7 @@ _G.fd,_G.io = {},{} function io.write(d) -- writes *d* to stdout fd[os.getenv("t") or 1].write(d) end -function io.read(d,b) -- reads *d* from stdin, until something is returned, or the thing returned equals *b* +function io.read(d,b) -- reads *d* from stdin, until something is returned, or b is true local r = "" repeat r=fd[os.getenv("t") or 1].read(d) @@ -63,3 +63,12 @@ function io.open(f,m) -- opens file *f* with mode *m* return t end end +do + local fdi,nfd = io.newfd() + function nfd.read() + end + function nfd.write() + end + function nfd.close() + end +end