1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #26304 from OctopusDeploy/26178-env-vars-with-equals

Allow windows environment variables to contain `=`
This commit is contained in:
Brian Goff 2016-09-06 09:32:40 -04:00 committed by GitHub
commit 778acfdf09
2 changed files with 14 additions and 1 deletions

View file

@ -10,7 +10,7 @@ import (
func setupEnvironmentVariables(a []string) map[string]string {
r := make(map[string]string)
for _, s := range a {
arr := strings.Split(s, "=")
arr := strings.SplitN(s, "=", 2)
if len(arr) == 2 {
r[arr[0]] = arr[1]
}

View file

@ -0,0 +1,13 @@
package libcontainerd
import (
"testing"
)
func TestEnvironmentParsing(t *testing.T) {
env := []string{"foo=bar", "car=hat", "a=b=c"}
result := setupEnvironmentVariables(env)
if len(result) != 3 || result["foo"] != "bar" || result["car"] != "hat" || result["a"] != "b=c" {
t.Fatalf("Expected map[foo:bar car:hat a:b=c], got %v", result)
}
}