Interrupting lua interpretation without ctrl -c output

I run code from book programming in Lua ... http://www.lua.org/pil/3.6.html

when I run this code in a terminal interpreter ... it keeps reading input forever ...

list = nil for line in io.lines() do list = {next=list, value=line} end 

Ctrl C brings me back to the / bash prompt. Is there any other team to break? How can I break / return from a piece of lua code without exiting the interpreter?

+7
lua break interpreter
source share
2 answers

By pressing Ctrl-C on a Unix-like system, you send your process a SIGINT signal, which will terminate the process by default.

Your program continues reading from input forever, because it blocks the call to io.lines() , which saves reading from standard input. To interrupt it, send the EOF terminal, this is done by pressing Ctrl-D on a Unix-like system.

On Windows, the key to send EOF is Ctrl-Z .

+4
source share

You can specify the end of input for stdin using either Ctrl-Z or Ctrl-D .

+3
source share

All Articles