From 6bb56f91d36443c7e81bf1afce72a1f5cb851418 Mon Sep 17 00:00:00 2001 From: Nathan LeClaire Date: Tue, 5 May 2015 13:51:22 -0700 Subject: [PATCH] Fix failing env validation Signed-off-by: Nathan LeClaire --- commands/env.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/commands/env.go b/commands/env.go index 73e6167b6d..20d696a791 100644 --- a/commands/env.go +++ b/commands/env.go @@ -1,6 +1,7 @@ package commands import ( + "errors" "fmt" "net/url" "os" @@ -17,6 +18,10 @@ const ( envTmpl = `{{ .Prefix }}DOCKER_TLS_VERIFY{{ .Delimiter }}{{ .DockerTLSVerify }}{{ .Suffix }}{{ .Prefix }}DOCKER_HOST{{ .Delimiter }}{{ .DockerHost }}{{ .Suffix }}{{ .Prefix }}DOCKER_CERT_PATH{{ .Delimiter }}{{ .DockerCertPath }}{{ .Suffix }}{{ .UsageHint }}` ) +var ( + improperEnvArgsError = errors.New("Error: Expected either one machine name, or -u flag to unset the variables in the arguments.") +) + type ShellConfig struct { Prefix string Delimiter string @@ -28,8 +33,8 @@ type ShellConfig struct { } func cmdEnv(c *cli.Context) { - if len(c.Args()) > 1 { - log.Fatal("Error: Expected either a machine name, or -u flag to unset the variables in the arguments.") + if len(c.Args()) != 1 && !c.Bool("unset") { + log.Fatal(improperEnvArgsError) } userShell := c.String("shell") if userShell == "" {