From: Olga Arkhangelskaia <arkholga@tarantool.org>
To: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH] console: add line carrying backslash
Date: Tue, 14 Apr 2020 15:35:04 +0300 [thread overview]
Message-ID: <20200414123504.48100-1-arkholga@tarantool.org> (raw)
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
---
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)
next reply other threads:[~2020-04-14 12:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-14 12:35 Olga Arkhangelskaia [this message]
2020-05-26 12:11 ` Igor Munkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200414123504.48100-1-arkholga@tarantool.org \
--to=arkholga@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH] console: add line carrying backslash' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox