--- loncom/build/filecompare.pl 2001/12/06 23:14:33 1.10 +++ loncom/build/filecompare.pl 2004/07/02 22:04:50 1.14 @@ -3,7 +3,7 @@ # The LearningOnline Network with CAPA # filecompare.pl - script used to help probe and compare file statistics # -# $Id: filecompare.pl,v 1.10 2001/12/06 23:14:33 harris41 Exp $ +# $Id: filecompare.pl,v 1.14 2004/07/02 22:04:50 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -72,7 +72,7 @@ Options (before file/dir names): -a show all files (with comparisons) -q only show file names (based on first file/dir) -v verbose mode (default) --bN buildmode (controls exit code of this script; 0 unless...) +-bN buildmode (controls EXIT code of this script; 0 unless...) N=1: md5sum=same --> 1; cvstime<0 --> 2 N=2: same as N=1 except without md5sum N=3: md5sum=same --> 1; age<0 --> 2 @@ -269,6 +269,7 @@ my %MEASURE=( my $rv2=`wc -l $file2`; chop $rv2; return ($rv1,$rv2); } ), 'diffs'=>( sub { my ($file1,$file2)=@_; + return (0,0); my $rv1=`diff $file1 $file2 | grep '^<' | wc -l`; chop $rv1; $rv1=~s/^\s+//; $rv1=~s/\s+$//; my $rv2=`diff $file1 $file2 | grep '^>' | wc -l`; @@ -423,7 +424,7 @@ FLOOP: foreach my $file (@files) { $showflag=1; } } - if ($buildmode==1) { + if ($buildmode==1) { # -b1 if ($md5sum eq 'same') { exit(1); } @@ -434,7 +435,7 @@ FLOOP: foreach my $file (@files) { exit(0); } } - elsif ($buildmode==2) { + elsif ($buildmode==2) { # -b2 if ($cvstime<0) { exit(2); } @@ -442,7 +443,7 @@ FLOOP: foreach my $file (@files) { exit(0); } } - elsif ($buildmode==3) { + elsif ($buildmode==3) { # -b3 if ($md5sum eq 'same') { exit(1); } @@ -453,7 +454,7 @@ FLOOP: foreach my $file (@files) { exit(0); } } - elsif ($buildmode==4) { + elsif ($buildmode==4) { # -b4 if ($existence=~/no$/) { exit(3); } @@ -503,12 +504,18 @@ sub cvstime { } my $cvstime; if ($buildmode!=3) { - my $entry=`grep '^/$file/' ${path}CVS/Entries` or - die('*** ERROR *** cannot grep against '.${path}. - 'CVS/Entries for ' .$file . "\n"); - my @fields=split(/\//,$entry); - $cvstime=`date -d '$fields[3] UTC' --utc +"%s"`; - chomp $cvstime; + my $entry=`grep '^/$file/' ${path}CVS/Entries 2>/dev/null`; +# or +# die('*** WARNING *** cannot grep against '.${path}. +# 'CVS/Entries for ' .$file . "\n"); + if ($entry) { + my @fields=split(/\//,$entry); + $cvstime=`date -d '$fields[3] UTC' --utc +"%s"`; + chomp $cvstime; + } + else { + $cvstime='n/a'; + } } else { $cvstime='n/a';