#!/usr/bin/perl ###################################################################### # cvsroots -- Mike Schilli, 2004 (m@perlmeister.com) ###################################################################### my %roots; our $CVSVERSION = '$Revision: 1.3 $'; for(<*/CVS/Root>) { open FILE, "<$_" or die "Cannot open $_"; my $root = ; chomp $root; $roots{$root}++; close FILE; } my $picked = pick(keys %roots); print "$picked\n"; ############################################################# sub pick { ############################################################# my(@options) = @_; die "Nothing to pick from" unless @options; my $counter = 1; for(@options) { print STDERR "[", $counter++, "] $_\n"; } $| = 1; print STDERR "[1..", $counter-1, "]>"; my $input = ; chomp $input; return $options[$input-1]; } __END__ =head1 NAME cvsroot_select - Select a CVS root from all subdirectories under the current one =head1 DOWNLOAD _SRC_HERE_ =head1 SYNOPSIS cvsroot_select =head1 DESCRIPTION B finds all C files in all directories under the current one, displays a list of CVSROOTs used and prompts the user to pick one. It should be used in conjunction with a bash shell function like function cvsr () { export CVSROOT=`cvsroot_select $1`; echo $CVSROOT } to let the user select one of the CVSROOTs already used in one of the projects under the current directory. =head1 LEGALESE Copyright 2004 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR 2004, Mike Schilli