+use strict;
+use warnings;
+use Smart::Comments;
+use lib 'tools';
+require 'utils.pl';
+use File::Spec;
+use File::Compare;
+use File::Copy;
+
+sub main {
+ while (defined(my $arg = <>)) {
+ chomp $arg;
+
+ my $rel = File::Spec->file_name_is_absolute($arg)
+ ? File::Spec->abs2rel($arg, $ENV{HOME})
+ : $arg;
+ my $abs = File::Spec->rel2abs($rel, $ENV{HOME});
+ my $saved = rel2saved($rel);
+
+ if (!-e $saved) {
+ print "SKIP: $rel is not in the repository.\n";
+ next;
+ }
+ elsif (-e $abs) {
+ if (compare($abs, $saved) == 0) {
+ print "SKIP: $rel is identical to the copy in the repository.\n";
+ }
+ else {
+ print "SKIP: $rel is different from the copy in the repository.\n";
+ }
+ }
+ else {
+ print "Copying $saved to $abs...\n";
+ copy($saved, $abs) or die $!;
+ }
+ }
+}
+
+main();