lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
> Behalf Of Coda Highland
> Sent: zaterdag 7 december 2013 11:29
> To: Lua mailing list
> Subject: Re: Read user input from terminal when a pipe is used
> 
> On Sat, Dec 7, 2013 at 2:22 AM, Thijs Schreijer <thijs@thijsschreijer.nl>
> wrote:
> > just curious; is there a windows way of doing this?
> 
> Windows has the CON: special file that's conceptually equivalent to
> /dev/tty but I don't know if it works the same way, and I don't have a
> way to test it at the moment.
> 
> /s/ Adam

It works;

=8x=CODE: testcon.lua =================
local r = ""
while r do
	r = io.read()
    if r then print(">" .. r) end
end
local terminal = io.open("CON:")
print("--"..terminal:read())


=8x=OUTPUT=============================
C:\Temp>type testcon.lua | testcon.lua
>local r = ""
>while r do
>       r = io.read()
>    if r then print(">" .. r) end
>end
>local terminal = io.open("CON:")
>print("--"..terminal:read())
typed from terminal
--typed from terminal

C:\Temp>


Thijs