From: Sergey Matveev Date: Mon, 23 Nov 2020 10:12:50 +0000 (+0300) Subject: Fix relative default.do paths X-Git-Tag: v0.2.0~5 X-Git-Url: http://www.git.cypherpunks.ru/?p=goredo.git;a=commitdiff_plain;h=c5123973b6ebfa2273f0ea3fa02aa35d329bae4d Fix relative default.do paths --- diff --git a/run.go b/run.go index 93c837d..bb3604b 100644 --- a/run.go +++ b/run.go @@ -275,10 +275,6 @@ func runScript(tgtOrig string, errs chan error, traced bool) error { cleanup() return TgtErr{tgtOrig, errors.New("no .do found")} } - if err = writeDep(fdDep, cwd, doFile); err != nil { - cleanup() - return TgtErr{tgtOrig, err} - } // Determine basename and DIRPREFIX ents := strings.Split(cwd, "/") @@ -289,24 +285,29 @@ func runScript(tgtOrig string, errs chan error, traced bool) error { cwd = path.Join(cwd, "..") } cwd = path.Clean(cwd) + doFilePath := path.Join(cwd, doFile) basename := tgt runErr := RunErr{Tgt: tgtOrig} if strings.HasPrefix(doFile, "default.") { basename = tgt[:len(tgt)-(len(doFile)-len("default.")-len(".do"))-1] runErr.DoFile = doFile } + + if err = writeDep(fdDep, cwd, doFile); err != nil { + cleanup() + return TgtErr{tgtOrig, err} + } trace(CWait, "%s", runErr.Name()) - doFile = path.Base(doFile) // Prepare command line var cmdName string var args []string - if err = unix.Access(path.Join(cwd, doFile), unix.X_OK); err == nil { + if err = unix.Access(doFilePath, unix.X_OK); err == nil { // Ordinary executable file - cmdName = doFile + cmdName = doFilePath args = make([]string, 0, 3) } else { - fd, err := os.Open(path.Join(cwd, doFile)) + fd, err := os.Open(doFilePath) if err != nil { cleanup() return TgtErr{tgtOrig, err}