#! /bin/csh -f # Last modified on Fri Jan 16 03:05:53 1987 by stolfi # Compares the local copy of $1 with its remote copy. # # If both are links to the same thing, says so # and returns. # # If both are directories, lists the components of one that # are not in the other, and calls itself recursively # on the common elements. # # If both are simple files, checks if they have the same # contents, size, and mtime. # # Complains in all other cases. #================================================================ if (($#argv != 1) || ("$1" !~ /udir/*)) then echo 'usage: compare-versions /udir/' exit(1) endif set h = "/"`homeserver` set d = $1 if (! (-e ${h}${d})) then echo "*** No remote version: $d" exit endif set a = `expandpath $d` set b = `expandpath ${h}${d}` if ("x$a" == "x$b") then echo "Linked to same file: $d = ${h}${d} = $a" exit endif if (-d $d) then if (! (-d $b)) then echo "*** Remote version not a directory: ${h}${d}" ls -ld $d ls -ld ${h}${d} endif echo "Comparing directories: $d and ${h}${d} ..." ls -a $d | sed '/\.,.*/d' > ,tmp1 ls -a $b | sed '/\.,.*/d' > ,tmp2 foreach f (`comm -13 ,tmp1 ,tmp2`) echo "*** No local version: ${h}${d}/$f" end foreach f (`comm -23 ,tmp1 ,tmp2`) echo "*** No remote version: ${d}/$f" end foreach f (`comm -12 ,tmp1 ,tmp2`) if (("$f" != '.') && ("$f" != '..')) then set fa = `expandpath ${d}/$f` set fb = `expandpath ${h}${d}/$f` if ("${fa}" == "${fb}") then echo "Same file: ${d}/$f = ${h}${d}/$f = ${fa}" else if ((-f ${d}/$f) && (-f ${fb})) then if ( { cmp -s ${d}/$f ${fb} } ) then echo "Local and remote versions agree: ${d}/$f" else echo "*** Local and remote versions differ: ${d}/$f" ls -ld ${d}/$f ls -ld ${h}${d}/$f endif else echo ' ' compare-versions "${d}/$f" endif endif end exit endif if ((-d $b) && (! (-d $a))) then echo "*** Local version not a directory: $d" ls -ld $d ls -ld ${h}${d} exit endif if (-f $d) then if ( { cmp -s $d $b } ) then echo "Local and remote versions agree: $d" else echo "*** Local and remote versions differ: $d # ${h}${d}" ls -ld $d ls -ld ${h}${d} endif exit else echo "*** Cannot figure out file types: $d ${h}${d}" ls -ld $d ls -ld ${h}${d} endif #===============================================================