[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Why no unbuffered read from stdin?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 7 Mar 2018 22:02:08 +0200
If I say, while running Lua in interactive mode,
c = io.read(1)
and I type a character, nothing happens. I need to hit 'return'.
If I then say
d = io.read(1)
it immediately returns, and c has the character I typed first,
while d contains \n.
I.e. even when reading a fixed number of bytes from stdin,
you need to end with "return",
The way I read the Linux-supplied documentation, this behaviour
depends on a setting called "cbreak mode". If that had been set
the other way, I would indeed have a finished read of one character
from that first io.read(1).
Is there any way one can set cbreak from Lua?