[lxc-devel] [lxd/master] Use os.LookupEnv from go 1.5 to find environment vars

techtonik on Github lxc-bot at linuxcontainers.org
Thu Aug 18 05:46:12 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 358 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160818/173a4ba9/attachment.bin>
-------------- next part --------------
From 072d90d0aad87f541728a3d7fc4fab82b3051d4e Mon Sep 17 00:00:00 2001
From: anatoly techtonik <techtonik at gmail.com>
Date: Thu, 18 Aug 2016 08:34:10 +0300
Subject: [PATCH] Use os.LookupEnv from go 1.5 to find environment vars

https://github.com/golang/go/issues/9676#issuecomment-99163260

Signed-off-by: anatoly techtonik <techtonik at gmail.com>
---
 lxc/exec.go | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lxc/exec.go b/lxc/exec.go
index 87427ed..58702d5 100644
--- a/lxc/exec.go
+++ b/lxc/exec.go
@@ -96,11 +96,8 @@ func (c *execCmd) run(config *lxd.Config, args []string) error {
 	}
 
 	env := map[string]string{"HOME": "/root", "USER": "root"}
-	myEnv := os.Environ()
-	for _, ent := range myEnv {
-		if strings.HasPrefix(ent, "TERM=") {
-			env["TERM"] = ent[len("TERM="):]
-		}
+	if myTerm, ok := os.LookupEnv("TERM"): ok {
+		env["TERM"] = myTerm
 	}
 
 	for _, arg := range c.envArgs {


More information about the lxc-devel mailing list