Skip to content

Commit

Permalink
console: add line carrying backslash
Browse files Browse the repository at this point in the history
When using interactive console(stdin) instead of \set delimiter <delimiter>
with "\", "\" in the end if line can be used.

The patch enables "\" only for REPL over stdin. I have troubles to write
tests for stdin input, because in case we attach to the console (remote
or to self) another read (console_read) is used. And in this case I do
not think that we need support backslash, because we stop reading
till "\n" or "\r".
Another problem that I have faced is testing (I have tried remote instance,
console over socket and i little bit of popen. However, all this test take
advantage of console_read and do not touch local_read.
If you have any ideas how to test interactive
console within test-run, please share.

Closes #4317
  • Loading branch information
Olga Arkhangelskaia committed Apr 14, 2020
1 parent 1f0211b commit 10d7d4b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/box/lua/console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,20 @@ local function local_read(self)
break
end
if delim == "" then
local lang = box.session.language
if not lang or lang == 'lua' then
-- stop once a complete Lua statement is entered
if local_check_lua(buf) then
-- if no delim is set and line ends with the backslash
-- continue reading
if buf:sub(-1, -1) == '\\' then
buf = buf:sub(0, #buf - 1)
else
local lang = box.session.language
if not lang or lang == 'lua' then
-- stop once a complete Lua statement is entered
if local_check_lua(buf) then
break
end
else
break
end
else
break
end
elseif #buf >= #delim and buf:sub(#buf - #delim + 1) == delim then
buf = buf:sub(0, #buf - #delim)
Expand Down

0 comments on commit 10d7d4b

Please sign in to comment.