X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=run.go;h=40fad74af0f20f98dc517020faca88c86df57359;hb=edb601644735972fac3efcdc27849b5b9b1f5fb7;hp=589889e3db6edbf62f51f626e5f9ed04394323fd;hpb=3a29962a4bfcb0cf6cdfd112fb87f68751b0a0dc;p=goredo.git diff --git a/run.go b/run.go index 589889e..40fad74 100644 --- a/run.go +++ b/run.go @@ -1,6 +1,6 @@ /* goredo -- redo implementation on pure Go -Copyright (C) 2020 Sergey Matveev +Copyright (C) 2020-2021 Sergey Matveev 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 @@ -458,14 +458,16 @@ func runScript(tgtOrig string, errs chan error, traced bool) error { } // Was $1 touched? - if fd, err := os.Open(path.Join(cwdOrig, tgt)); err == nil { - ts, err := fileCtime(fd) - fd.Close() - if err == nil && ts != tsPrev { - runErr.Err = errors.New("$1 was explicitly touched") - errs <- runErr + if tsPrev != "" { + if fd, err := os.Open(path.Join(cwdOrig, tgt)); err == nil { + ts, err := fileCtime(fd) fd.Close() - return + if err == nil && ts != tsPrev { + runErr.Err = errors.New("$1 was explicitly touched") + errs <- runErr + fd.Close() + return + } } } @@ -505,6 +507,7 @@ func runScript(tgtOrig string, errs chan error, traced bool) error { // Do we need to ifcreate it, of ifchange with renaming? if fd == nil { + os.Remove(path.Join(cwdOrig, tgt)) err = ifcreate(fdDep, tgt) if err != nil { goto Finish