lua-users home
lua-l archive

Re: Right way to emty stdin?

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


On 2011年2月23日 14:57:14 +0200, steve donovan
<steve.j.donovan@gmail.com> wrote:
>You did say ctrl-Z (Windows) or ctrl-D (Unix) ?
The script is launched by the server, not manually.
I modified the script so I can run it manually, and it turns out that
"if line == nil" doesn't break from the while loop:
============
# cat test.lua
#!/usr/bin/lua
--Must first empty stdin
while true do
 local line = io.read()
 -- BAD if line == nil then break end
 if line == "" then break end
 -- Without line below, script never ends
 -- io.write("NOOP ",line,"\n")
end
print("Hello")
============
# ./test.lua
test
test
Hello
#
============
If it works fine when ran manually, I can't find why the script
doesn't proceed when called from the server :-/
Thank you.

AltStyle によって変換されたページ (->オリジナル) /