#!/bin/sh
# -*- perl -*-
# This code allows us to start perl from our path or an environment variable
# rather than hardcoding a path into the #! line.  It works from sh or csh.
(exit $?0) && eval 'exec ${QPERLQ-perl} -x $0 ${1+"$@"}'
if (! $?QPERLQ) setenv QPERLQ perl
exec $QPERLQ -x $0 $argv:q

#!/usr/local/bin/perl -w
#
# $Id: new_cvs_tag,v 1.3 1998/03/11 16:18:24 ejb Exp $
# $Source: /home/ejb/scripts/RCS/new_cvs_tag,v $
# $Author: ejb $
#

require 5.002;
use strict;

my $whoami = ($0 =~ m,([^/\\]*)$,) ? $1 : $0;
#my $dirname = ($0 =~ m,(.*)[/\\][^/\\]+$,) ? $1 : ".";

&usage() unless (@ARGV >= 2);
my ($id, $n, @modules) = (@ARGV);

my @time = localtime;
my ($yr, $mo, $day) = ($time[5] + 1900, $time[4] + 1, $time[3]);
my $user = $ENV{'LOGNAME'} || $ENV{'USER'} || getlogin || (getpwuid($<))[0]
    or die "$whoami: can't determine username\n";
my $branchtag = sprintf("$user-work-$id--%04d-%02d-%02d-$n", $yr, $mo, $day);
my $trunktag = "$branchtag-bp";
print "$branchtag\n";
print STDERR "Creating $branchtag and its branchpoint\n";

my $modules = join(' ', @modules);
((system("cvs 1>&2 rtag $trunktag $modules") == 0) &&
 (system("cvs 1>&2 rtag -b $branchtag $modules")));

exit $?;

sub usage
{
    die "Usage: $whoami id n modules\n";
}
