Skip to content

Commit

Permalink
connect: fix terminal after executing os.exit()
Browse files Browse the repository at this point in the history
Fixed terminal brake after os.exit() in tt connect session.
Have done it by adding workaround for the bug(c-bata/go-prompt#228)
in case of executing os.exit().

Closes #425
  • Loading branch information
better0fdead committed Apr 28, 2023
1 parent 3f0a696 commit b7c928b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- ``--dynamic`` option for `tt install tarantool` command to build non-static tarantool executable.

### Fixed

- ``tt connect`` command does not break a console after executing `os.exit()` command anymore.

## [1.0.2] - 2023-04-21

### Fixed
Expand Down
6 changes: 6 additions & 0 deletions cli/connect/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ func (console *Console) Close() {
if console.conn != nil {
console.conn.Close()
}
// Workaround bug https://github.com/c-bata/go-prompt/issues/228
rawModeOff := exec.Command("/bin/stty", "-raw", "echo")
rawModeOff.Stdin = os.Stdin
_ = rawModeOff.Run()
rawModeOff.Wait()
}

func loadHistory(console *Console) error {
Expand Down Expand Up @@ -247,6 +252,7 @@ func getExecutor(console *Console) prompt.Executor {
var data string
if _, err := console.conn.Eval(consoleEvalFuncBody, args, opts); err != nil {
if err == io.EOF {
console.Close()
log.Fatalf("Connection was closed. Probably instance process isn't running anymore")
} else {
log.Fatalf("Failed to execute command: %s", err)
Expand Down

0 comments on commit b7c928b

Please sign in to comment.