Skip to content

Commit

Permalink
Merge pull request #37 from msoap/windows_env_bug
Browse files Browse the repository at this point in the history
Fixed pass PATH environment variable on Windows
  • Loading branch information
msoap committed Jan 21, 2018
2 parents bb167f0 + fae7026 commit b378587
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion shell2http.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,10 @@ func isMultipartFormData(headers http.Header) bool {
func proxySystemEnv(cmd *exec.Cmd, appConfig Config) {
varsNames := []string{"PATH", "HOME", "LANG", "USER", "TMPDIR"}

if runtime.GOOS == "windows" {
varsNames = append(varsNames, "USERNAME", "USERPROFILE", "HOMEDRIVE", "HOMEPATH", "TEMP", "TMP", "PATHEXT", "COMSPEC", "OS")
}

if appConfig.exportVars != "" {
varsNames = append(varsNames, strings.Split(appConfig.exportVars, ",")...)
}
Expand All @@ -638,7 +642,7 @@ func proxySystemEnv(cmd *exec.Cmd, appConfig Config) {
cmd.Env = append(cmd.Env, envRaw)
} else {
for _, envVarName := range varsNames {
if env[0] == envVarName {
if strings.ToUpper(env[0]) == envVarName {
cmd.Env = append(cmd.Env, envRaw)
}
}
Expand Down

0 comments on commit b378587

Please sign in to comment.