git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Added get sendmail from .mailrc

From
Kyle J. McKay <mackyle@gmail.com>
Date
Jan 28, 2014, 06:19 UTC
Message-ID
<1B2852B7-5CDB-4C8E-AF0D-5375DB95A4AB@gmail.com>
In-Reply-To
<20140128011512.GB17945@sigill.intra.peff.net>
On Jan 27, 2014, at 17:15, Jeff King wrote:
Show 5 quoted lines
> 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.

Show 22 quoted lines
>> +			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
Previous: Jeff King
Message 8 of 8 in “Added get sendmail from .mailrc”
  1. Added get sendmail from .mailrcBrilliantov Kirill Vladimirovich, Jan 25, 2014
  2. Eric WongJan 25, 2014
  3. Brilliantov Kirill VladimirovichJan 26, 2014
  4. Brilliantov Kirill VladimirovichJan 26, 2014
  5. Eric WongJan 26, 2014
  6. Jeff KingJan 28, 2014
  7. Jeff KingJan 28, 2014
  8. Kyle J. McKayJan 28, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.