Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] console: add line carrying backslash
@ 2020-04-14 12:35 Olga Arkhangelskaia
  2020-05-26 12:11 ` Igor Munkin
  0 siblings, 1 reply; 2+ messages in thread
From: Olga Arkhangelskaia @ 2020-04-14 12:35 UTC (permalink / raw)
  To: tarantool-patches

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)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-26 12:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 12:35 [Tarantool-patches] [PATCH] console: add line carrying backslash Olga Arkhangelskaia
2020-05-26 12:11 ` Igor Munkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox