Browse Source

Merge pull request #32817 from vdemeester/fix-win-it

Fix docker run -it on windows
John Howard 8 years ago
parent
commit
d4fb626e36
3 changed files with 24 additions and 12 deletions
  1. 12 1
      cli/command/in.go
  2. 12 1
      cli/command/out.go
  3. 0 10
      cli/command/stream.go

+ 12 - 1
cli/command/in.go

@@ -2,9 +2,11 @@ package command
 
 import (
 	"errors"
-	"github.com/docker/docker/pkg/term"
 	"io"
+	"os"
 	"runtime"
+
+	"github.com/docker/docker/pkg/term"
 )
 
 // InStream is an input stream used by the DockerCli to read user input
@@ -22,6 +24,15 @@ func (i *InStream) Close() error {
 	return i.in.Close()
 }
 
+// SetRawTerminal sets raw mode on the input terminal
+func (i *InStream) SetRawTerminal() (err error) {
+	if os.Getenv("NORAW") != "" || !i.CommonStream.isTerminal {
+		return nil
+	}
+	i.CommonStream.state, err = term.SetRawTerminal(i.CommonStream.fd)
+	return err
+}
+
 // CheckTty checks if we are trying to attach to a container tty
 // from a non-tty client input stream, and if so, returns an error.
 func (i *InStream) CheckTty(attachStdin, ttyMode bool) error {

+ 12 - 1
cli/command/out.go

@@ -1,9 +1,11 @@
 package command
 
 import (
+	"io"
+	"os"
+
 	"github.com/Sirupsen/logrus"
 	"github.com/docker/docker/pkg/term"
-	"io"
 )
 
 // OutStream is an output stream used by the DockerCli to write normal program
@@ -17,6 +19,15 @@ func (o *OutStream) Write(p []byte) (int, error) {
 	return o.out.Write(p)
 }
 
+// SetRawTerminal sets raw mode on the input terminal
+func (o *OutStream) SetRawTerminal() (err error) {
+	if os.Getenv("NORAW") != "" || !o.CommonStream.isTerminal {
+		return nil
+	}
+	o.CommonStream.state, err = term.SetRawTerminalOutput(o.CommonStream.fd)
+	return err
+}
+
 // GetTtySize returns the height and width in characters of the tty
 func (o *OutStream) GetTtySize() (uint, uint) {
 	if !o.isTerminal {

+ 0 - 10
cli/command/stream.go

@@ -2,7 +2,6 @@ package command
 
 import (
 	"github.com/docker/docker/pkg/term"
-	"os"
 )
 
 // CommonStream is an input stream used by the DockerCli to read user input
@@ -22,15 +21,6 @@ func (s *CommonStream) IsTerminal() bool {
 	return s.isTerminal
 }
 
-// SetRawTerminal sets raw mode on the input terminal
-func (s *CommonStream) SetRawTerminal() (err error) {
-	if os.Getenv("NORAW") != "" || !s.isTerminal {
-		return nil
-	}
-	s.state, err = term.SetRawTerminal(s.fd)
-	return err
-}
-
 // RestoreTerminal restores normal mode to the terminal
 func (s *CommonStream) RestoreTerminal() {
 	if s.state != nil {