[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Options: `--dry-run' should prevent `--touch' from touching

From: Michael Witten
Subject: [PATCH] Options: `--dry-run' should prevent `--touch' from touching
Date: Tue, 8 Mar 2011 21:37:40 +0000

The `--dry-run' flag is supposed to be safe in that nothing
in the file system is actually modified. Unfortunately,
the `--touch' flag completely ignores this fact, resulting
in all kinds of unsavory and inappropriate touching.

This patch quashes such deviant behavior and ensures future
compliance by introducing a test.

Signed-off-by: Michael Witten <address@hidden>
 remake.c                     |    3 +++
 tests/scripts/options/dash-n |   15 +++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/remake.c b/remake.c
index 97e3854..91a70cc 100644
--- a/remake.c
+++ b/remake.c
@@ -1113,6 +1113,9 @@ touch_file (struct file *file)
   if (!silent_flag)
     message (0, "touch %s", file->name);
+  if (just_print_flag)
+    return 0;
 #ifndef        NO_ARCHIVES
   if (ar_name (file->name))
     return ar_touch (file->name);
diff --git a/tests/scripts/options/dash-n b/tests/scripts/options/dash-n
index de19f42..fd13cbd 100644
--- a/tests/scripts/options/dash-n
+++ b/tests/scripts/options/dash-n
@@ -65,6 +65,21 @@ $answer = "$make_name: `a' is up to date.\n";
 $answer = "$make_name: `a' is up to date.\n";
 &compare_output($answer, &get_logfile(1));
+# TEST 4
+unlink('a', 'b');
+&run_make_with_options($makefile2, "-t -n", &get_logfile);
+open(DASH_N_LOG, ">>" . &get_logfile(1));
+print DASH_N_LOG "a exists but should not!\n" if -e 'a';
+print DASH_N_LOG "b exists but should not!\n" if -e 'b';
+&compare_output("touch b\ntouch a\n", &get_logfile(1));
 unlink('a', 'b', 'c');

reply via email to

[Prev in Thread] Current Thread [Next in Thread]