]> git.ipfire.org Git - thirdparty/git.git/commitdiff
send-email: implement sendmail aliases line continuation support
authorEric Sunshine <sunshine@sunshineco.com>
Sun, 31 May 2015 22:29:29 +0000 (18:29 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Jun 2015 22:53:11 +0000 (15:53 -0700)
Logical lines in sendmail aliases files can be spread over multiple
physical lines[1]. A line beginning with whitespace is folded into the
preceding line. A line ending with '\' consumes the following line.

[1]: https://www.freebsd.org/cgi/man.cgi?query=aliases&sektion=5

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-send-email.txt
git-send-email.perl

index e6d466e9a5a8ce0bdb1d795e43ae3dd7415105f4..7ae467ba415e5cb4413d0246883b8a620b8960e3 100644 (file)
@@ -394,8 +394,6 @@ described below:
 sendmail;;
 *      Quoted aliases and quoted addresses are not supported: lines that
        contain a `"` symbol are ignored.
-*      Line continuations are not supported: lines that start with
-       whitespace characters, or end with a `\` symbol are ignored.
 *      Redirection to a file (`/path/name`) or pipe (`|command`) is not
        supported.
 *      File inclusion (`:include: /path/name`) is not supported.
index e777bd3a60b16f735733df8d30e9e6b273857f2e..eb1d678fb016d0918caf96897a89ecba9ed4fc47 100755 (executable)
@@ -492,8 +492,6 @@ sub parse_sendmail_alias {
        local $_ = shift;
        if (/"/) {
                print STDERR "warning: sendmail alias with quotes is not supported: $_\n";
-       } elsif (/^\s|\\$/) {
-               print STDERR "warning: sendmail continuation line is not supported: $_\n";
        } elsif (/^(\S+?)\s*:\s*(.+)$/) {
                my ($alias, $addr) = ($1, $2);
                $aliases{$alias} = [ split_addrs($addr) ];
@@ -504,10 +502,16 @@ sub parse_sendmail_alias {
 
 sub parse_sendmail_aliases {
        my $fh = shift;
+       my $s = '';
        while (<$fh>) {
+               chomp;
                next if /^\s*$/ || /^\s*#/;
-               parse_sendmail_alias($_);
+               $s .= $_, next if $s =~ s/\\$// || s/^\s+//;
+               parse_sendmail_alias($s) if $s;
+               $s = $_;
        }
+       $s =~ s/\\$//; # silently tolerate stray '\' on last line
+       parse_sendmail_alias($s) if $s;
 }
 
 my %parse_alias = (