[lxc-devel] [distrobuilder/master] *: Remove init() code

monstermunchkin on Github lxc-bot at linuxcontainers.org
Wed Feb 21 18:29:54 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 380 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180221/cd98ff08/attachment.bin>
-------------- next part --------------
From 6db895de08aaede6bfcae3a4da794f476e70cc15 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Wed, 21 Feb 2018 19:28:28 +0100
Subject: [PATCH] *: Remove init() code

Resolves #12.

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 distrobuilder/main.go | 6 ------
 shared/util.go        | 5 +++++
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/distrobuilder/main.go b/distrobuilder/main.go
index 48e90ec..f25b8ee 100644
--- a/distrobuilder/main.go
+++ b/distrobuilder/main.go
@@ -60,12 +60,6 @@ import (
 	yaml "gopkg.in/yaml.v2"
 )
 
-func init() {
-	os.Setenv("PATH", "/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin")
-	os.Setenv("SHELL", "/bin/sh")
-	os.Setenv("TERM", "xterm")
-}
-
 func main() {
 	app := cli.NewApp()
 	app.Usage = "image generator"
diff --git a/shared/util.go b/shared/util.go
index ddac11c..f18daaa 100644
--- a/shared/util.go
+++ b/shared/util.go
@@ -40,6 +40,11 @@ func Copy(src, dest string) error {
 func RunCommand(name string, arg ...string) error {
 	cmd := exec.Command(name, arg...)
 
+	cmd.Env = []string{
+		"PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin",
+		"SHELL=/bin/sh",
+		"TERM=xterm"}
+
 	cmd.Stdin = os.Stdin
 	cmd.Stdout = os.Stdout
 	cmd.Stderr = os.Stderr


More information about the lxc-devel mailing list