diff --git a/lib.go b/lib.go index f17bcd4..a8e6953 100644 --- a/lib.go +++ b/lib.go @@ -174,6 +174,12 @@ func Lines(str string) ([]Line, error) { line.LType = LINETYPE_CHANGEWD } + if runtime.GOOS == "windows" && (line.LType == LINETYPE_SERIAL || line.LType == LINETYPE_PARALLEL) { + if !strings.HasSuffix(line.Tokens[0], ".exe") { + line.Tokens[0] = line.Tokens[0] + ".exe" + } + } + ret = append(ret, line) } @@ -411,3 +417,25 @@ func Kill(p int) error { } } + +// Simple Runs a simple command line +func Simple(str string) (*exec.Cmd, error) { + wd, err := os.Getwd() + if err != nil { + return nil, err + } + + lines, err := Lines(str) + if err != nil { + return nil, err + } + + l := lines[0] + fqncmd, err := exec.LookPath(l.Tokens[0]) + if err != nil { + fqncmd = filepath.Join(wd, l.Tokens[0]) + } + cmd := exec.Command(fqncmd, l.Tokens[1:]...) + return cmd, nil + +}