changing exec to always use abs path

master
Paulo Simão 2021-10-29 18:26:21 -03:00
parent b9b75192c5
commit 93c21fac65
1 changed files with 5 additions and 1 deletions

6
lib.go
View File

@ -239,7 +239,11 @@ func Exec(str string, opts ...*Opts) ([]*exec.Cmd, error) {
cmdwd = filepath.Join(wd, cmdwd) cmdwd = filepath.Join(wd, cmdwd)
} }
prepCmd := func(l Line) *exec.Cmd { prepCmd := func(l Line) *exec.Cmd {
cmd := exec.Command(l.Tokens[0], l.Tokens[1:]...) fqncmd, err := exec.LookPath(l.Tokens[0])
if err != nil {
fqncmd = filepath.Join(cmdwd, l.Tokens[0])
}
cmd := exec.Command(fqncmd, l.Tokens[1:]...)
cmd.Stdout = log.Writer() cmd.Stdout = log.Writer()
cmd.Stderr = log.Writer() cmd.Stderr = log.Writer()
cmd.Dir = cmdwd cmd.Dir = cmdwd