lua-users home
lua-l archive

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


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?