]> Cypherpunks.ru repositories - goredo.git/blobdiff - run.go
Download link for 2.0.0 release
[goredo.git] / run.go
diff --git a/run.go b/run.go
index 283ebc9b673b07cdc78f1e164842ac8c07055e8d..15628ddccfdf9d6ac9fc76d1f39618e977ac1750 100644 (file)
--- a/run.go
+++ b/run.go
@@ -133,7 +133,7 @@ func mkdirs(pth string) error {
 }
 
 func isModified(dep *Dep, tgt *Tgt) (
-       modified bool, ourInode Inode, hshPrev Hash, err error,
+       modified bool, ourInode *Inode, hshPrev Hash, err error,
 ) {
        if dep == nil {
                return
@@ -628,14 +628,14 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
                                line = scanner.Text()
                                if strings.HasPrefix(line, childStderrPrefix) {
                                        line = line[len(childStderrPrefix):]
+                                       LogMutex.Lock()
                                        os.Stderr.WriteString(StderrPrefix + line + "\n")
+                                       LogMutex.Unlock()
                                        continue
                                }
                                if fdStderr != nil {
                                        ts.FromTime(time.Now())
-                                       LogMutex.Lock()
                                        fmt.Fprintln(fdStderr, tai64n.Encode(ts[:]), line)
-                                       LogMutex.Unlock()
                                }
                                if StderrSilent {
                                        continue
@@ -666,7 +666,7 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
 
                // Was $1 touched?
                if inode, err := inodeFromFileByPath(tgt.a); err == nil {
-                       if inodePrev == "" {
+                       if inodePrev == nil {
                                runErr.Err = Err1WasTouched
                                errs <- runErr
                                return
@@ -709,12 +709,13 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
                                err = ErrLine(err)
                                goto Finish
                        }
+                       defer fd.Close()
                        if fi, rerr := fd.Stat(); rerr == nil {
                                chmod = fi.Mode()
                        } else {
-                               err = rerr
+                               err = ErrLine(rerr)
+                               goto Finish
                        }
-                       defer fd.Close()
                } else if fiStdout.Size() > 0 {
                        fd = fdStdout
                }