4 # Subroutine mh_profile
5 # Parse the user's .mh_profile and get arguments and settings
10 ($PROFILE = $ENV{"MH"}) || ($PROFILE = $ENV{"HOME"} . "/.mh_profile");
12 open PROFILE || "$0: can't read mh_profile $PROFILE: $!\n";
16 next unless ($key, $value) = /([^:\s]+):\s*(.+)/;
22 $MH{'path'} = $ENV{'HOME'} . '/' . $MH{'path'};
28 # Convenience routine for MH users. Pipes incoming
29 # mail message to rcvstore. Expects one argument - the
30 # name of the folder to rcvstore into.
35 &openpipe("/usr/local/bin/mh/lib/rcvstore +$folder -create");
41 # Convenience routine for MH users. Pipes incoming
42 # mail message to rcvdist. Expects one argument - the
43 # list of users to distribute the mail message to
48 &openpipe("/usr/local/bin/mh/lib/rcvdist $recips");
54 # Convenience routine for MH users. Pipes incoming
55 # mail message to rcvtty. This is MH's version of biff.
59 &openpipe("/usr/local/bin/mh/lib/rcvtty");
65 # Expand an MH alias into a list of names usable by
73 $recips = `/usr/local/bin/mh/ali $alias`;
75 return(@list) if ($alias eq $recips);
77 @list = split(/,/, $recips);
83 # Subroutine refile_from
84 # Refile a message into a folder by organization and
85 # sender name. The top-level folder is an argument
86 # the user can specify.
89 local($toplevel) = @_;
91 return if (length($from) <= 0);
92 return if ($from eq $user);
94 $toplevel = "log" if ($toplevel eq '');
95 &rcvstore("$toplevel/$organization/$from");
99 # Subroutine make_mhpath
100 # Make a directory path recursively.
107 $mode = oct($MH{'folder-protect'}) if (defined $MH{'folder-protect'});
110 s#^/.*#/# || s#^[^/].*#.#;
112 foreach $i (split('/', $dir)) {
113 $start = $start . '/' . $i;
115 mkdir($start, $mode) || return(1);
123 # Subroutine mh_parse
124 # Parse the command line options
127 local(@argdesc) = @SW;
130 while (($#ARGV >= 0) && ($ARGV[0] !~ /^-.+/)) { # must be a message list
131 push(@MSGS, shift @ARGV);
134 grep(s/(\W)/\\$1/g, @argdesc);
136 @ARGV = (split(' ', $MH{$program}), @ARGV) if defined($MH{$program});
138 return if ($#ARGV < 0);
140 while ($ARGV[0] =~ /^-.+/) {
144 unless (@matches = grep(/$ARGV/, @argdesc)) {
145 print "$program: unknown option: $ARGV\n";
150 for (@matches) { s/\\(\W)/$1/g; }
152 if ($#matches > $[) {
153 print "$program: ambiguous switch $ARGV matches:\n";
155 print "\ ", $_, "\n";
160 ($switch,$wantarg) = $matches[$[] =~ /^-(\S+)\s*(\S*)/;
162 $SW{$switch} = $wantarg ? shift @ARGV : 1;
163 if ($SW{$switch} =~ /^(['"]).*$/ && $SW{$switch} !~ /^(['"]).*\1$/) {
165 $SW{$switch} .= ' ' . (shift @ARGV);
166 } until $#ARGV < 0 || $SW{$switch} =~ /^(['"]).*\1$/;
167 $SW{$switch} =~ s/^(['"])(.*)\1$/$2/;
174 # Subroutine print_switches
175 # print the valid command line switches
178 local(@argdesc) = @SW;
180 print " switches are:\n";