Add CVS 1.12.12.
[dragonfly.git] / contrib / cvs-1.12.12 / contrib / mfpipe.in
1 #! @PERL@ -T
2 # -*-Perl-*-
3
4 ###############################################################################
5 ###############################################################################
6 ###############################################################################
7 #
8 # THIS SCRIPT IS PROBABLY BROKEN.  REMOVING THE -T SWITCH ON THE #! LINE ABOVE
9 # WOULD FIX IT, BUT THIS IS INSECURE.  WE RECOMMEND FIXING THE ERRORS WHICH THE
10 # -T SWITCH WILL CAUSE PERL TO REPORT BEFORE RUNNING THIS SCRIPT FROM A CVS
11 # SERVER TRIGGER.  PLEASE SEND PATCHES CONTAINING THE CHANGES YOU FIND
12 # NECESSARY TO RUN THIS SCRIPT WITH THE TAINT-CHECKING ENABLED BACK TO THE
13 # <bug-cvs@gnu.org> MAILING LIST.
14 #
15 # For more on general Perl security and taint-checking, please try running the
16 # `perldoc perlsec' command.
17 #
18 ###############################################################################
19 ###############################################################################
20 ###############################################################################
21
22 # From: clyne@niwot.scd.ucar.EDU (John Clyne)
23 # Date: Fri, 28 Feb 92 09:54:21 MST
24
25 # BTW, i wrote a perl script that is similar to 'nfpipe' except that in
26 # addition to logging to a file it provides a command line option for mailing
27 # change notices to a group of users. Obviously you probably wouldn't want
28 # to mail every change. But there may be certain directories that are commonly
29 # accessed by a group of users who would benefit from an email notice. 
30 # Especially if they regularly beat on the same directory. Anyway if you 
31 # think anyone would be interested here it is. 
32 #
33 #       File:           mfpipe
34 #
35 #       Author:         John Clyne
36 #                       National Center for Atmospheric Research
37 #                       PO 3000, Boulder, Colorado
38 #
39 #       Date:           Wed Feb 26 18:34:53 MST 1992
40 #
41 #       Description:    Tee standard input to mail a list of users and to
42 #                       a file. Used by CVS logging.
43 #
44 #       Usage:          mfpipe [-f file] [user@host...]
45 #
46 #       Environment:    CVSROOT 
47 #                               Path to CVS root.
48 #
49 #       Files:
50 #
51 #
52 #       Options:        -f file 
53 #                               Capture output to 'file'
54 #                       
55
56 $header = "Log Message:\n";
57
58 $mailcmd = "| mail -s  'CVS update notice'";
59 $whoami = `whoami`;
60 chop $whoami;
61 $date = `date`;
62 chop $date;
63
64 $cvsroot = $ENV{'CVSROOT'};
65
66 while (@ARGV) {
67         $arg = shift @ARGV;
68
69         if ($arg eq '-f') {
70                 $file = shift @ARGV;
71         }
72         else {
73                 $users = "$users $arg";
74         }
75 }
76
77 if ($users) {
78         $mailcmd = "$mailcmd $users";
79         open(MAIL, $mailcmd) || die "Execing $mail: $!\n";
80 }
81  
82 if ($file) {
83         $logfile = "$cvsroot/LOG/$file";
84         open(FILE, ">> $logfile") || die "Opening $logfile: $!\n";
85 }
86
87 print FILE "$whoami $date--------BEGIN LOG ENTRY-------------\n" if ($logfile);
88
89 while (<>) {
90         print FILE $log if ($log && $logfile);
91
92         print FILE $_ if ($logfile);
93         print MAIL $_ if ($users);
94
95         $log = "log: " if ($_ eq $header);
96 }
97
98 close FILE;
99 die "Write failed" if $?;
100 close MAIL;
101 die "Mail failed" if $?;
102
103 exit 0;