]> Cypherpunks.ru repositories - goredo.git/blobdiff - run.go
Use more shorter Cwd-relative paths
[goredo.git] / run.go
diff --git a/run.go b/run.go
index 903a063c283b53136eb5475ac15f5d05c9a6388e..7fa4deae08c35b428111e5773d5744eca32417cd 100644 (file)
--- a/run.go
+++ b/run.go
@@ -21,7 +21,6 @@ package main
 
 import (
        "bufio"
-       "bytes"
        "crypto/rand"
        "encoding/hex"
        "errors"
@@ -112,7 +111,7 @@ type RunError struct {
 func (e *RunError) Name() string {
        var name string
        if e.DoFile == "" {
-               name = e.Tgt.String()
+               name = e.Tgt.rel
        } else {
                name = fmt.Sprintf("%s (%s)", e.Tgt, e.DoFile)
        }
@@ -134,7 +133,7 @@ func mkdirs(pth string) error {
 }
 
 func isModified(depInfo *DepInfo, tgt *Tgt) (
-       modified bool, ourInode *Inode, hshPrev []byte, err error,
+       modified bool, ourInode *Inode, hshPrev Hash, err error,
 ) {
        if depInfo == nil {
                return
@@ -351,11 +350,11 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
                doFile = NewTgt(path.Join(ups...))
                if strings.HasPrefix(doFile.t, "default.") {
                        basename = basename[:len(basename)-(len(doFile.t)-len("default.")-len(".do"))-1]
-                       runErr.DoFile = doFile.String()
+                       runErr.DoFile = doFile.rel
                }
        }
 
-       if err = depWrite(fdDep, tgt.h, doFile, nil); err != nil {
+       if err = depWrite(fdDep, tgt.h, doFile, ""); err != nil {
                cleanup()
                return TgtError{tgt, ErrLine(err)}
        }
@@ -366,7 +365,7 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
        // Prepare command line
        var cmdName string
        var args []string
-       if err = unix.Access(doFile.String(), unix.X_OK); err == nil {
+       if err = unix.Access(doFile.rel, unix.X_OK); err == nil {
                cmdName = doFile.t
                args = make([]string, 0, 3)
        } else {
@@ -666,11 +665,6 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
                                errs <- runErr
                                return
                        }
-                       if err != nil {
-                               runErr.Err = err
-                               errs <- runErr
-                               return
-                       }
                        if !inode.Equals(inodePrev) {
                                runErr.Err = Err1WasTouched
                                errs <- runErr
@@ -722,8 +716,8 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
                                goto Finish
                        }
                } else {
-                       var hsh []byte
-                       if hshPrev != nil {
+                       var hsh Hash
+                       if hshPrev != "" {
                                _, err = fd.Seek(0, io.SeekStart)
                                if err != nil {
                                        err = ErrLine(err)
@@ -734,7 +728,7 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
                                        err = ErrLine(err)
                                        goto Finish
                                }
-                               if bytes.Equal(hsh, hshPrev) {
+                               if hsh == hshPrev {
                                        tracef(CDebug, "%s has same hash, not renaming", tgt)
                                        err = ErrLine(os.Remove(fd.Name()))
                                        if err != nil {