Skip to content

Commit

Permalink
Merge pull request #1233 from fuweid/bugfix_set_raw_mode_should_use_i…
Browse files Browse the repository at this point in the history
…n_tty

bugfix: setRawMode can only be set when the user set tty
  • Loading branch information
HusterWan authored Apr 27, 2018
2 parents 98ec8f3 + 57a77ff commit a51e352
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,17 @@ func (rc *RunCommand) runRun(args []string) error {
wait := make(chan struct{})

if rc.attach || rc.stdin {
in, out, err := setRawMode(rc.stdin, false)
if err != nil {
return fmt.Errorf("failed to set raw mode")
}
defer func() {
if err := restoreMode(in, out); err != nil {
fmt.Fprintf(os.Stderr, "failed to restore term mode")
if rc.tty {
in, out, err := setRawMode(rc.stdin, false)
if err != nil {
return fmt.Errorf("failed to set raw mode")
}
}()
defer func() {
if err := restoreMode(in, out); err != nil {
fmt.Fprintf(os.Stderr, "failed to restore term mode")
}
}()
}

conn, br, err := apiClient.ContainerAttach(ctx, containerName, rc.stdin)
if err != nil {
Expand Down

0 comments on commit a51e352

Please sign in to comment.