Work around MinGW mangling of "host:/path"
[msysgit/historical-msysgit.git] / lib / cvs / contrib / mfpipe
blob6dd18c4dd7b9c0df16a038a6e9c9d45d14693b63
1 #! /bin/perl
2 # -*-Perl-*-
4 # From: clyne@niwot.scd.ucar.EDU (John Clyne)
5 # Date: Fri, 28 Feb 92 09:54:21 MST
6 #
7 # BTW, i wrote a perl script that is similar to 'nfpipe' except that in
8 # addition to logging to a file it provides a command line option for mailing
9 # change notices to a group of users. Obviously you probably wouldn't want
10 # to mail every change. But there may be certain directories that are commonly
11 # accessed by a group of users who would benefit from an email notice.
12 # Especially if they regularly beat on the same directory. Anyway if you
13 # think anyone would be interested here it is.
15 # File: mfpipe
17 # Author: John Clyne
18 # National Center for Atmospheric Research
19 # PO 3000, Boulder, Colorado
21 # Date: Wed Feb 26 18:34:53 MST 1992
23 # Description: Tee standard input to mail a list of users and to
24 # a file. Used by CVS logging.
26 # Usage: mfpipe [-f file] [user@host...]
28 # Environment: CVSROOT
29 # Path to CVS root.
31 # Files:
34 # Options: -f file
35 # Capture output to 'file'
38 $header = "Log Message:\n";
40 $mailcmd = "| mail -s 'CVS update notice'";
41 $whoami = `whoami`;
42 chop $whoami;
43 $date = `date`;
44 chop $date;
46 $cvsroot = $ENV{'CVSROOT'};
48 while (@ARGV) {
49 $arg = shift @ARGV;
51 if ($arg eq '-f') {
52 $file = shift @ARGV;
54 else {
55 $users = "$users $arg";
59 if ($users) {
60 $mailcmd = "$mailcmd $users";
61 open(MAIL, $mailcmd) || die "Execing $mail: $!\n";
64 if ($file) {
65 $logfile = "$cvsroot/LOG/$file";
66 open(FILE, ">> $logfile") || die "Opening $logfile: $!\n";
69 print FILE "$whoami $date--------BEGIN LOG ENTRY-------------\n" if ($logfile);
71 while (<>) {
72 print FILE $log if ($log && $logfile);
74 print FILE $_ if ($logfile);
75 print MAIL $_ if ($users);
77 $log = "log: " if ($_ eq $header);
80 close FILE;
81 die "Write failed" if $?;
82 close MAIL;
83 die "Mail failed" if $?;
85 exit 0;