git-lfs/subprocess/subprocess_windows.go
brian m. carlson 59f1496289
subprocess: don't initialize environment at startup
Currently, the subprocess package reads from the environment as it's
created at startup when the init function is called.  However, we'll
soon want to modify the environment in this case before it gets
processed, so let's change the code to use a mutex to initialize the
environment once before using it and simply call that before using the
environment we've set up.

We'll want to reset the environment as well in a future commit, so let's
be sure to add a function for that.  We reuse the same internal function
and just ignore the return value to make our code paths simpler.
2020-10-14 16:49:23 +00:00

17 lines
345 B
Go

// +build windows
package subprocess
import (
"os/exec"
"syscall"
)
// ExecCommand is a small platform specific wrapper around os/exec.Command
func ExecCommand(name string, arg ...string) *Cmd {
cmd := exec.Command(name, arg...)
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
cmd.Env = fetchEnvironment()
return newCmd(cmd)
}