added err and lookup
parent
1c1151ffd6
commit
214a77730b
15
lib.go
15
lib.go
|
@ -390,14 +390,18 @@ func ExecStr(str string, opts ...*Opts) (string, error) {
|
|||
|
||||
cmdwd := opt.Wd
|
||||
|
||||
prepCmd := func(l Line) *exec.Cmd {
|
||||
cmd := exec.Command(l.Tokens[0], l.Tokens[1:]...)
|
||||
prepCmd := func(l Line) (*exec.Cmd, error) {
|
||||
str, err := exec.LookPath(l.Tokens[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cmd := exec.Command(str, l.Tokens[1:]...)
|
||||
cmd.Stdout = log.Writer()
|
||||
cmd.Stderr = log.Writer()
|
||||
cmd.Dir = cmdwd
|
||||
opt.SetupProc(cmd)
|
||||
ret = append(ret, cmd)
|
||||
return cmd
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
lines, err := Lines(str)
|
||||
|
@ -423,7 +427,10 @@ func ExecStr(str string, opts ...*Opts) (string, error) {
|
|||
log.Printf("CMDWD NOW IS: %s", cmdwd)
|
||||
continue
|
||||
case LINETYPE_SERIAL, LINETYPE_PARALLEL:
|
||||
cmd := prepCmd(l)
|
||||
cmd, err := prepCmd(l)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if opt.Debug {
|
||||
log.Printf("Running %s from dir %s with params %v", cmd.Path, cmd.Dir, cmd.Args)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue