From c0377ebb5f4aa5d8eda7a74bdefa51e13a88f802 Mon Sep 17 00:00:00 2001
From: Leonid Vasiliev <lvasiliev@tarantool.org>
Date: Thu, 14 Apr 2022 17:52:24 +0300
Subject: [PATCH] connect: fix work with terminal

The patch adds a workaround for the bug "Terminal does
not display command after go-prompt exit"
(https://github.com/c-bata/go-prompt/issues/228).

Part of #15
---
 cli/connect/console.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/cli/connect/console.go b/cli/connect/console.go
index 209aff368..bdca838de 100644
--- a/cli/connect/console.go
+++ b/cli/connect/console.go
@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"io"
 	"os"
+	"os/exec"
 	"path/filepath"
 	"sort"
 	"strings"
@@ -128,6 +129,11 @@ func (console *Console) Run() error {
 
 	console.prompt.Run()
 
+	// Sets the terminal modes to “sane” values to workaround
+	// bug https://github.com/c-bata/go-prompt/issues/228
+	reinitialization := exec.Command("reset")
+	_ = reinitialization.Run()
+
 	return nil
 }