docker save: Do not save to a terminal.

Pretty straightforward, something I noticed while triaging an issue.

The "cowardly refusing" is a hat-tip to gzip which says something similar when you try to do this.
Updated.

On Oct 6, 2014, at 9:01 AM, Tibor Vass <notifications@github.com> wrote:

> In integration-cli/docker_cli_save_load_test.go:
> 
> > +	cmd.Stdout = tty
> > +	cmd.Stderr = tty
> > +	if err := cmd.Start(); err != nil {
> > +		t.Fatalf("start err: %v", err)
> > +	}
> > +	if err := cmd.Wait(); err == nil {
> > +		t.Fatal("did not break writing to a TTY")
> > +	}
> > +
> > +	buf := make([]byte, 1024)
> > +
> > +	if _, err := pty.Read(buf); err != nil {
> > +		t.Fatal("could not read tty output")
> > +	}
> > +
> > +	if !strings.Contains(string(buf), "Cowardly refusing") {
> @erikh 
> Let's try to use the bytes package wherever possible. Also, buf has 1024 length even if Read did not read 1024 bytes. I suggest the following:
> 
> n, err := pty.Read(buf)
> if err != nil { ... }
> if !bytes.Contains(buf[:n], []byte("Cowardly refusing")) { ... }
> —
> Reply to this email directly or view it on GitHub.
>