mkrcs - perl script to check in a whole tree

Paul Vixie vixie at pa.dec.com
Sun Feb 10 05:16:03 AEST 1991


#! /usr/local/bin/perl

# mkrcs - create any missing RCS subdirectories, check in all text files
#	will use "ci -k" if there are RCS keywords in the text.
# 09feb91 vixie at decwrl [written]

chop($cwd = `pwd`);
foreach $d (@ARGV) {
	chdir("$cwd/$d") || die "$cwd/$d: $!";
	&mkrcs();
}
exit 0;

sub mkrcs {
	local($has_rcs) = 0;
	local(@f) = ();
	local(*d, *f);
	local($k);

	print "RCS'ing in ".`pwd`;
	opendir(d, '.') || die "opendir: $!";
	while ($f = readdir(d)) {
		next if ($f =~ /^\./);		# begins with .
		next if (-l $f);		# is a symlink
		if (-f $f) {			# is a plain file
			push(@f, $f);
			next;
		}
		next if (! -d $f);		# isn't a dir
		if ($f eq 'RCS') {		# name is RCS
			$has_rcs++;
			next;
		}
		chdir($f) || die "$f: $!";
		&mkrcs();
		chdir('..') || die "..: $!";
	}
	if (! $has_rcs) {
		mkdir("RCS", 0777) || die "mkdir RCS: $!";
	}
	while ($f = pop(@f)) {
		open(f, "<$f") || die "$f: $!";
		next unless (-T f);			# text file
		next if (-f "$f,v" || -f "RCS/$f,v");	# already in RCS
		$k = '';
		while (<f>) {
			if (/\$(Header|Version):/) {
				$k = '-k ';
				last;
			}
		}
		$_ = "ci -u $k -t/dev/null -morig $f";
		print "$_\n";
		system $_;
	} continue {
		close(f);
	}
}

--
Paul Vixie
DEC Western Research Lab	<vixie at wrl.dec.com>
Palo Alto, California		...!decwrl!vixie



More information about the Alt.sources mailing list