lua-users home
lua-l archive

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


A call to io.read() between the two loadfile()() statements
fixes the problem (Linux again).

$ lua
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> loadfile()()
print"Executed by anonymous function"
Executed by anonymous function
> s=io.read()
Checking that one can still read
> =s
Checking that one can still read
> loadfile()()
print"In that case, surely io.stdin is still present?"
In that case, surely io.stdin is still present?
>

2014/1/21 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
>> Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
>> >loadfile()()
>> print("Hello,")
>> ^Z
>> Hello,
>> >loadfile()()
>> print(" world!")
>
> In Mac OS X (10.7.5), the second loadfile does nothing, which is as
> expected, since stdin has already reached EOF by the ^D after the first
> loadfile. I've seen programs in Linux being able to read from stdin just
> fine after it had reached EOF, but it is not be expected, is it?
>