diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua index 52df674651cd2a53bd999c305cdadf036252cc0d..d4d8ec984eeb1ab58a1a45c7e4bba521f88cd7c6 100644 --- a/src/box/lua/console.lua +++ b/src/box/lua/console.lua @@ -323,7 +323,7 @@ local function preprocess(storage, line) end if items == nil then local msg = "Invalid command \\%s. Type \\help for help." - return format(false, msg:format(items[1])) + return format(false, msg:format(line)) end return operators[items[1]](storage, unpack(items)) end diff --git a/test/app-tap/console.test.lua b/test/app-tap/console.test.lua index 9e8b41b84e59b0fb0026f853867cb59526aa52a5..da5c1e71eae05ccebbb080c3d2d03e8d4af587e7 100755 --- a/test/app-tap/console.test.lua +++ b/test/app-tap/console.test.lua @@ -21,7 +21,7 @@ local EOL = "\n...\n" test = tap.test("console") -test:plan(72) +test:plan(73) -- Start console and connect to it local server = console.listen(CONSOLE_SOCKET) @@ -292,6 +292,20 @@ client:write("box.session.type();\n") test:is(yaml.decode(client:read(EOL))[1], "console", "session type") client:close() +-- +-- An unknown backslash started command causes abnormal exit of +-- a console. +-- +local cmd = '\\unknown_command' +local exp_res = {error = string.format( + 'Invalid command %s. Type \\help for help.', cmd)} +client = socket.tcp_connect("unix/", CONSOLE_SOCKET) +client:read(128) +client:write(('%s\n'):format(cmd)) +local res = yaml.decode(client:read(EOL))[1] +test:is_deeply(res, exp_res, 'unknown command') +client:close() + server:close() box.schema.user.drop('test')