]> Cypherpunks.ru repositories - goredo.git/commitdiff
Fix relative default.do paths
authorSergey Matveev <stargrave@stargrave.org>
Mon, 23 Nov 2020 10:12:50 +0000 (13:12 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 23 Nov 2020 10:12:50 +0000 (13:12 +0300)
run.go

diff --git a/run.go b/run.go
index 93c837d9fb458dca6c4bffbe62c120da60aa387f..bb3604bf4ba29feb289bc834a66242c94b023782 100644 (file)
--- 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}