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 27, 2023
1 parent 3f0a696 commit ffbaeaa
Show file tree
Hide file tree
Showing 2 changed files with 12 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
8 changes: 8 additions & 0 deletions cli/connect/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ func getExecutor(console *Console) prompt.Executor {
var data string
if _, err := console.conn.Eval(consoleEvalFuncBody, args, opts); err != nil {
if err == io.EOF {
if strings.Contains(console.input, "os.exit(") {
console.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()
}
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 ffbaeaa

Please sign in to comment.