File: compare

package info (click to toggle)
fsvs 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,964 kB
  • ctags: 1,464
  • sloc: ansic: 16,650; sh: 5,885; perl: 783; makefile: 338; python: 90
file content (59 lines) | stat: -rwxr-xr-x 1,337 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl

use Getopt::Std;

getopts("dmx:h");

$s=shift;
$d=shift;
die <<'EOF'
Need two directories to compare, and maybe
   -d             ignore dir-mtime
   -m             expect mismatch in directory listing
   -x <pattern>   ignore changes that match this pattern
EOF
if $opt_h || !($s && $d);


# find /tmp/fsvs-test-1000/wc-1/ -printf "% y%04m %7s %5G %5U %T+ %P\0\t%l\0\n"
# strace -o /tmp/asdga -f -tt 
$cmd=qq'LANG=C rsync -ain --delete "$s" "$d" -c';
@changes=();
for (`$cmd`)
{
# Ignore empty lines.
  next if m(^\s*$);

# ignore root directory
  next if m(\.d......... \./\s*$);

# ignore mtime of links
  next if m(\.L\.\.t\.\.\.\.\.\. .* -> );
# and directories
  next if $opt_d && m(\.d\.\.t\.\.\.\.\.\. .*);

  next if $opt_x && m($opt_x)o;

# everything else is a change.
  push @changes, $_;
#.L..t...... typechange/device-symlink -> device-1
#>fc........ typechange/dir-file
#.L..t...... typechange/file-symlink -> file-1
#cL+++++++++ typechange/symlink-symlink -> symlink-1
}

$SIG{"__DIE__"} = sub { print STDERR '$ ',$cmd,"\n",@changes,@_; exit 1; };

if ($opt_m && @changes)
{
  print "----- expected differences\n";
# pass output for further processing
  print @changes;
  exit 0;
}

die "----- Differences were found\n" if @changes;

print "----- comparison of directory gave no differences\n";
exit 0;