From b04949af1a8186606e7f71f78365bb164c71d55f Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Fri, 20 May 2011 10:56:11 -0400 Subject: [PATCH] h-c: add headings for each type of comparison Without headings, it's non-obvious which sections correspond to which comparisons in the output file. This information was printed to standard output, but not to the output file. So I added this information to the output file as well. My knowledge of Perl is limited so I just used system("/bin/echo .."); for now. It would be good to fix that later. I've added a copyright notice for myself, since this change is probably significant enough to be copyrightable. --- hierarchy-comparison | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hierarchy-comparison b/hierarchy-comparison index f921df3..dc35e3f 100755 --- a/hierarchy-comparison +++ b/hierarchy-comparison @@ -2,6 +2,7 @@ # hierarchy-comparison -*- Perl -*- # Possible bug: only -type f and -type d are checked # Copyright (C) 2001, 2002, 2003, 2004, 2008 Bradley M. Kuhn +# Copyright (C) 2011 Denver Gingerich # # This software's license gives you freedom; you can copy, convey, # propogate, redistribute and/or modify this program under the terms of @@ -122,6 +123,8 @@ my(@comparedNonRegular) = FindAndSortOutput("NON-REGULAR", $comparedDir, $comparedTempFile, $ignoreRegex, "^/?($origDir|$comparedDir)/?"); +# TODO: use the right Perl mechanism instead of /bin/echo (ossguy) +system("/bin/echo Directory comparison: >> $diffOutputFile 2>&1"); system( "/usr/bin/diff -u $origTempFile $comparedTempFile >> $diffOutputFile 2>&1"); @@ -147,6 +150,10 @@ my(@orgFiles) = FindAndSortOutput("FILES", $origDir, $origTempFile, my(@comparedFiles) = FindAndSortOutput("FILES", $comparedDir, $comparedTempFile, $ignoreRegex, "^/?($origDir|$comparedDir)/?"); +# TODO: use the right Perl mechanism instead of /bin/echo (ossguy) +system("/bin/echo >> $diffOutputFile 2>&1"); +system("/bin/echo File hierarchy comparison: >> $diffOutputFile 2>&1"); + system( "/usr/bin/diff -u $origTempFile $comparedTempFile >> $diffOutputFile 2>&1"); @@ -187,12 +194,20 @@ my(@o, @c); my $origFiles2sha1 = MD5SumFiles($origDir, \@o, $origTempFile); my $comparedFiles2sha1 = MD5SumFiles($comparedDir, \@c, $comparedTempFile); +# TODO: use the right Perl mechanism instead of /bin/echo (ossguy) +system("/bin/echo >> $diffOutputFile 2>&1"); +system("/bin/echo 'File contents comparisons (MD5):' >> $diffOutputFile 2>&1"); + system( "/usr/bin/diff -u $origTempFile $comparedTempFile >> $diffOutputFile 2>&1"); $diffExitCode = $?; unlink($origTempFile, $comparedTempFile); +# TODO: use the right Perl mechanism instead of /bin/echo (ossguy) +system("/bin/echo >> $diffOutputFile 2>&1"); +system("/bin/echo 'File contents comparisons (diff):' >> $diffOutputFile 2>&1"); + if ($DO_DIFF) { foreach my $file (keys %final) { if ($origFiles2sha1->{$file} ne $comparedFiles2sha1->{$file}) {