On Jan 27, 2014, at 17:15, Jeff King wrote:
On Sat, Jan 25, 2014 at 01:46:50PM +0400, Brilliantov Kirill
Vladimirovich wrote:
+ if (!defined $smtp_server) {
+ my $mailrc = File::HomeDir->my_home . "/.mailrc";
Actually, based on the output of "man mail", this should probably be
something more like
my $mailrc = $ENV{'MAILRC'} || "$ENV{'HOME'}/.mailrc";
which takes into account any MAILRC setting and also avoids the use of
File::HomeDir.
+ while (<FILE>) {
+ chomp;
+ if (/set sendmail=.*/) {
+ my @data = split '"';
+ $smtp_server = $data[1];
+ last;
+ }
Your split is a rather unusual way to do the parsing, and it took me a
minute to figure it out. It might be more obvious as:
if (/set sendmail="(.*)"/) {
$smtp_server = $1;
last;
}
I do not know anything about the mailrc format, nor does it seem to be
well documented. Are the double-quotes required? If not, then the
above
regex can easily make them optional. I also wonder if any whitespace
is
allowed.
From "man mail":
set (se) With no arguments, prints all variable values.
Otherwise,
sets option. Arguments are of the form option=value (no space
before or after `=') or option. Quotation marks may be placed
around any part of the assignment statement to quote blanks or
tabs, i.e. ``set indentprefix="->"''
My version of "man mail" does not list all the variables that can be
set but it refers to "The Mail Reference Manual" document which
presumably does. I did find this [1] that documents many of the
available variables including the sendmail one. I then tried this:
cat <<EOF > /tmp/shim
#!/bin/sh
exec cat
EOF
chmod a+x /tmp/shim
cat <<EOF > /tmp/testrc
se send"mail"=/tm"p/"shim
EOF
echo 'testing' | MAILRC=/tmp/testrc mail -s test nobody
And to my surprise the contents of the new message were cat'd out to
the terminal rather than being sent. So clearly there's some room for
improvement with the "set", white space and quote checking.
[1] http://www.cs.fsu.edu/sysinfo/mail/mailrc.html
--Kyle
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html