exec name collision

This commit is contained in:
asoseil 2017-11-11 22:53:29 +01:00
parent ae5497149d
commit bcd5b61918
1 changed files with 9 additions and 9 deletions

18
exec.go
View File

@ -148,26 +148,26 @@ func (p *Project) command(stop <-chan bool, cmd Command) (string, string) {
var stderr bytes.Buffer var stderr bytes.Buffer
done := make(chan error) done := make(chan error)
args := strings.Split(strings.Replace(strings.Replace(cmd.Command, "'", "", -1), "\"", "", -1), " ") args := strings.Split(strings.Replace(strings.Replace(cmd.Command, "'", "", -1), "\"", "", -1), " ")
exec := exec.Command(args[0], args[1:]...) ex := exec.Command(args[0], args[1:]...)
exec.Dir = p.Path ex.Dir = p.Path
// make cmd path // make cmd path
if cmd.Path != "" { if cmd.Path != "" {
if strings.Contains(cmd.Path, p.Path) { if strings.Contains(cmd.Path, p.Path) {
exec.Dir = cmd.Path ex.Dir = cmd.Path
} else { } else {
exec.Dir = filepath.Join(p.Path, cmd.Path) ex.Dir = filepath.Join(p.Path, cmd.Path)
} }
} }
exec.Stdout = &stdout ex.Stdout = &stdout
exec.Stderr = &stderr ex.Stderr = &stderr
// Start command // Start command
exec.Start() ex.Start()
go func() { done <- exec.Wait() }() go func() { done <- ex.Wait() }()
// Wait a result // Wait a result
select { select {
case <-stop: case <-stop:
// Stop running command // Stop running command
exec.Process.Kill() ex.Process.Kill()
return "", "" return "", ""
case err := <-done: case err := <-done:
// Command completed // Command completed