From 4efffe45bf019263394fc857add2a7e8b43035ee Mon Sep 17 00:00:00 2001
From: Konstantin Nazarov <mail@racktear.com>
Date: Fri, 1 Jul 2016 12:49:55 +0300
Subject: [PATCH] tarantoolctl connect doesn't report errors

This happens because console:eval swallows errors
and doesn't print them to stdout.

Also, console.connect() doesn't always call on_client_disconnect()
in case of errors, so the code that was meant to terminate local
session on errors, didn't do this in some cases and caused local
console to remain open.

Fixes #1586
---
 extra/dist/tarantoolctl.in | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index db74405690..373f52b4cc 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -547,9 +547,14 @@ local function enter()
 end
 
 local function connect()
-    local cmd = string.format("require('console').connect('%s')", arg[0])
-
-    console.on_start(function(self) self:eval(cmd) end)
+    console.on_start(function(self)
+        local status, reason
+        status, reason = pcall(function() require('console').connect(arg[0]) end)
+        if not status then
+            self:print(reason)
+            self.running = false
+        end
+    end)
     console.on_client_disconnect(function(self) self.running = false end)
     console.start()
     return 0
-- 
GitLab