]> Cypherpunks.ru repositories - goredo.git/commitdiff
Record relative path to .do
authorSergey Matveev <stargrave@stargrave.org>
Sat, 9 Jan 2021 13:00:07 +0000 (16:00 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 9 Jan 2021 14:43:23 +0000 (17:43 +0300)
run.go

diff --git a/run.go b/run.go
index f08547008d9f76a04e11b164be62e553bfa5a4c5..aab8e9a5c7eb4b9d6d1b41acce7939b14681544a 100644 (file)
--- a/run.go
+++ b/run.go
@@ -266,12 +266,14 @@ func runScript(tgtOrig string, errs chan error, traced bool) error {
        }
 
        // Determine basename and DIRPREFIX
+       doFileRelPath := doFile
        ents := strings.Split(cwd, "/")
        ents = ents[len(ents)-upLevels:]
        dirPrefix := path.Join(ents...)
        cwdOrig := cwd
        for i := 0; i < upLevels; i++ {
                cwd = path.Join(cwd, "..")
+               doFileRelPath = path.Join("..", doFileRelPath)
        }
        cwd = path.Clean(cwd)
        doFilePath := path.Join(cwd, doFile)
@@ -279,10 +281,10 @@ func runScript(tgtOrig string, errs chan error, traced bool) error {
        runErr := RunErr{Tgt: tgtOrig}
        if strings.HasPrefix(doFile, "default.") {
                basename = tgt[:len(tgt)-(len(doFile)-len("default.")-len(".do"))-1]
-               runErr.DoFile = doFile
+               runErr.DoFile = doFileRelPath
        }
 
-       if err = writeDep(fdDep, cwd, doFile); err != nil {
+       if err = writeDep(fdDep, cwdOrig, doFileRelPath); err != nil {
                cleanup()
                return TgtErr{tgtOrig, err}
        }