#!/usr/bin/perl -w # # $dotat: scripts/cvsroot,v 1.5 2002/12/16 21:17:00 fanf2 Exp $ use strict; use File::Find; use Getopt::Long; my %option; Getopt::Long::Configure 'bundling'; GetOptions (\%option, "test|t!", "verbose|v!") and @ARGV <= 1 or die "usage: cvsroot [-tv] [newroot]\n", "\t-t\ttest only\n", "\t-v\tverbose\n"; $option{verbose} = 1 if $option{test}; if (@ARGV < 1 or $option{verbose}) { for my $file ('CVS/Root', 'CVS/Repository') { open FILE, $file or die "open $file: $!\n"; print "$file = ", ; close FILE or die "close $file: $!\n"; } exit if @ARGV < 1; } my $root = { freebsd => 'fanf@ncvs.FreeBSD.org:/home/ncvs' }->{$ARGV[0]} || $ARGV[0]; $root .= "\n"; print "new root is $root" if $option{verbose}; sub action { return unless $File::Find::name =~ m|/CVS/Root$|; print "$File::Find::name\n" if $option{verbose}; return if $option{test}; open ROOT, "> $_" and print ROOT $root and close ROOT or warn "write > $File::Find::name: $!\n" } find \&action, '.';