From c5123973b6ebfa2273f0ea3fa02aa35d329bae4d Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Mon, 23 Nov 2020 13:12:50 +0300 Subject: [PATCH] Fix relative default.do paths --- run.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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} -- 2.44.0