diff --git a/commands/config.go b/commands/config.go index 936240df0b..0563c82b6b 100644 --- a/commands/config.go +++ b/commands/config.go @@ -3,6 +3,7 @@ package commands import ( "fmt" "net/url" + "os" "strings" "github.com/docker/machine/cli" @@ -14,6 +15,10 @@ import ( ) func cmdConfig(c *cli.Context) { + // Ensure that log messages always go to stderr when this command is + // being run (it is intended to be run in a subshell) + log.SetOutWriter(os.Stderr) + if len(c.Args()) != 1 { fatal(ErrExpectedOneMachine) } diff --git a/commands/env.go b/commands/env.go index 52d47b099a..72eeab55dd 100644 --- a/commands/env.go +++ b/commands/env.go @@ -8,6 +8,7 @@ import ( "text/template" "github.com/docker/machine/cli" + "github.com/docker/machine/libmachine/log" ) const ( @@ -32,6 +33,10 @@ type ShellConfig struct { } func cmdEnv(c *cli.Context) { + // Ensure that log messages always go to stderr when this command is + // being run (it is intended to be run in a subshell) + log.SetOutWriter(os.Stderr) + if len(c.Args()) != 1 && !c.Bool("unset") { fatal(improperEnvArgsError) }