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 <[email protected]> --- 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'; +close(DASH_N_LOG); + +&compare_output("touch b\ntouch a\n", &get_logfile(1)); + +# CLEANUP + unlink('a', 'b', 'c'); 1; -- 1.7.4.18.g68fe8 _______________________________________________ Bug-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-make
