From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [94.100.177.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id A620545C316 for ; Tue, 14 Apr 2020 15:35:14 +0300 (MSK) From: Olga Arkhangelskaia Date: Tue, 14 Apr 2020 15:35:04 +0300 Message-Id: <20200414123504.48100-1-arkholga@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH] console: add line carrying backslash List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org When using interactive console(stdin) instead of \set 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 --- Branch: OKriw/gh-4317-console-support-line-carrying-with-backslash src/box/lua/console.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua index 17e2c91b2..4c2c7a132 100644 --- a/src/box/lua/console.lua +++ b/src/box/lua/console.lua @@ -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) -- 2.20.1 (Apple Git-117)