Up to lua 2.4, there used to be an readuntil function that can read until the first occurence of a specified character; in 2.5 this is removed and you have to pass an appropriate pattern to file:read instead; and in 5.1 it seems that the available formatting option for read has been further reduced, and the patterns valid in version 2.5 are no longer available.
How do I read from an input stream until the first occurence of a given character, say TAB? Trying to write an enhanced REPL with tab-completion.
For tab-completion you need to read input in raw mode, that is, without waiting for a newline. This cannot be done in ANSI C.
Try a curses binding for instance: https://github.com/rrthomas/luaposix.