1 # "zap" files in a directory tree if they're the same as somewhere else
3 # zap normally means "rm", but "-s" means to put a symlink in place instead.
6 # # delete all files in this dir that are same as in master copy...
7 # % zap-if-same /src/ghc-master-copy
8 # # use lndir to put in mere links...
9 # % lndir /src/ghc-master-copy
11 # a similar effect can be had with just...
12 # % zap-if-same -s /src/ghc-master-copy
14 $Usage = "usage: zap-if-same [-s] master-dir\n";
18 if ($#ARGV >= 0 && $ARGV[0] eq '-s') {
26 $Master_dir = $ARGV[0];
27 die "no such dir: $Master_dir\n$Usage" if ! -d $Master_dir;
30 open(F,"find . -type f -print |") || die "Cannot open find ($!)";
34 if ( -f "$Master_dir/$_" && &same_contents($_) ) { # ToDo: & not same file?
35 print STDERR "$_ ...\n";
37 if ($Action eq 'link') {
38 symlink("$Master_dir/$_", $_);
47 local($return_val) = 0;
48 $return_val = system("cmp -s $Master_dir/$f $f") >> 8;
49 ($return_val == 0) ? 1 : 0;