#!/bin/sh
# $Id: cvs-add-recursive,v 1.2 2000/01/17 03:59:16 friedman Exp $

exec ${PERL-perl} -Sx $0 ${1+"$@"}
#!perl   [perl will skip all lines in this file before this line]

sub grind_over_cvs_tree ($$)
{
  my ($dir, $fn) = @_;

  return if (! -d $dir);
  return if (-d "$dir/CVS"); # Skip dirs already in CVS
  return print STDERR "chdir: $dir: $!\n" unless (chdir ($dir));
  return print STDERR "opendir: $dir: $!\n" unless (opendir (D, "."));
  my @files = grep (!/^\.\.?$/, readdir (D));
  closedir (D);
  &$fn (@files);
  for my $ent (@files) { grind_over_cvs_tree ($ent, $fn); }
  chdir ("..");
}

{
  for my $ent (@ARGV)
    {
      grind_over_cvs_tree ($ent, sub { system ("cvs", "add", @_); });
    }
}

# local variables:
# mode: perl
# eval: (auto-fill-mode 1)
# end:

# cvs-add-recursive ends here
