#!/afs/athena/contrib/perl/perl

for $new (@ARGV) {
    system("co -l $new");

    $old = $new.".bak";
    rename($new, $old);

    open(OLD, $old);
    open(NEW, ">$new");

    while(<OLD>) {
	next if (/\#\s*include\s+"sh.h"/);
	print NEW "#include \"sh.h\"\n\n" if /RCSID\s*\(/;
	print NEW $_;
    }

    close(NEW);
    close(OLD);

    system("rcsdiff -c $new");

    system("ci -u -m'moved sh.h before RCSID()' $new");
}
