diff --git a/cli/command/in.go b/cli/command/in.go index 815d2a2028..54855c6dc2 100644 --- a/cli/command/in.go +++ b/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 { diff --git a/cli/command/out.go b/cli/command/out.go index 622e758cc4..27b44c235d 100644 --- a/cli/command/out.go +++ b/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 { diff --git a/cli/command/stream.go b/cli/command/stream.go index 13a54cc672..71a43fa2e9 100644 --- a/cli/command/stream.go +++ b/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 {