From 6eaba253455c8e1b9632db465af1f98030138897 Mon Sep 17 00:00:00 2001 From: Leonid Vasiliev Date: Wed, 20 Apr 2022 13:02:16 +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). --- CHANGELOG.md | 7 +++++++ cli/connect/console.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 509a516cd..87937da92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Bug that caused a typed command not to be displayed on the terminal after + exiting the "connect" console. + ## [2.12.0] - 2022-03-30 ### Changed diff --git a/cli/connect/console.go b/cli/connect/console.go index 16ccb46d4..1426c53ef 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" @@ -134,6 +135,12 @@ 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 + sttySane := exec.Command("stty", "sane") + sttySane.Stdin = os.Stdin + _ = sttySane.Run() + return nil }