/*
goredo -- redo implementation on pure Go
-Copyright (C) 2020 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2020-2021 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Err error
}
-func (e RunErr) Unwrap() error { return e.Err }
-
func (e *RunErr) Name() string {
var name string
if e.DoFile == "" {
}
// 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)
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}
}
}
fdStderr.Truncate(0)
}
- shCtx := fmt.Sprintf("sh: %s: %s %s [%s]", tgtOrig, cmdName, args, cwd)
+ shCtx := fmt.Sprintf(
+ "sh: %s: %s %s cwd:%s dirprefix:%s",
+ tgtOrig, cmdName, args, cwd, dirPrefix,
+ )
trace(CDebug, "%s", shCtx)
Jobs.Add(1)