From 27e52f88774c1e61fef46ace84cde6f3160b2761 Mon Sep 17 00:00:00 2001 From: AndreyDobrovolskyOdessa Date: Thu, 18 Mar 2021 13:06:51 +0200 Subject: Changing order of creating files on find_dofile in run_script() In case of missing .do file .lock, .depend and .target files remains in the target directory. Calling find_dofile() before creating them helps to avoid such target directory pollution. Closes: #15 [via git-merge-pr] --- redo.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/redo.c b/redo.c index ef130f0..a702d0d 100644 --- a/redo.c +++ b/redo.c @@ -627,6 +627,12 @@ run_script(char *target, int implicit) target = targetchdir(target); + dofile = find_dofile(target); + if (!dofile) { + fprintf(stderr, "no dofile for %s.\n", target); + exit(1); + } + int lock_fd = open(targetlock(target), O_WRONLY | O_TRUNC | O_CREAT, 0666); if (lockf(lock_fd, F_TLOCK, 0) < 0) { @@ -645,12 +651,6 @@ run_script(char *target, int implicit) target_fd = mkstemp(temp_target_base); - dofile = find_dofile(target); - if (!dofile) { - fprintf(stderr, "no dofile for %s.\n", target); - exit(1); - } - fprintf(stderr, "redo%*.*s %s # %s\n", level*2, level*2, " ", orig_target, dofile); write_dep(dep_fd, dofile); -- cgit 1.4.1