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

[PATCH 7/9] send-email: implement sendmail aliases line continuation support

From
Eric Sunshine <sunshine@sunshineco.com>
Date
May 31, 2015, 22:29 UTC
Message-ID
<1433111371-19573-8-git-send-email-sunshine@sunshineco.com>
In-Reply-To
<1433111371-19573-1-git-send-email-sunshine@sunshineco.com>

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>
---

This implementation silently and "sanely" tolerates continuation line scenarios for which behavior is not defined by [1]. In particular, an indented line which is the first (non-comment) line in the file is treated as a single logical line. Ditto for a line ending with '\' which is the last (non-comment) line in the file.

An earlier iteration emitted warnings for such cases, but it wasn't clear if warning about undefined behavior was useful; and it made the implementation much more noisy, so this version silently tolerates such anomalies.

 Documentation/git-send-email.txt |  2 --
 git-send-email.perl              | 10 +++++++---
 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index e6d466e..7ae467b 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -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.
diff --git a/git-send-email.perl b/git-send-email.perl
index e777bd3..eb1d678 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -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 = (
-- 
2.4.2.538.g5f4350e
Previous: Eric SunshineNext: Eric Sunshine
Message 12 of 15 in “send-email: add sendmail aliases line continuation support”
  1. 0/9 send-email: add sendmail aliases line continuation supportEric Sunshine, May 31, 2015
  2. 1/9 send-email: further document missing sendmail aliases functionalityEric Sunshine, May 31, 2015
  3. Allen HubbeJun 1, 2015
  4. Eric SunshineJun 1, 2015
  5. Allen HubbeJun 1, 2015
  6. 2/9 send-email: visually distinguish sendmail aliases parser warningsEric Sunshine, May 31, 2015
  7. 3/9 send-email: drop noise comments which merely repeat what code saysEric Sunshine, May 31, 2015
  8. 4/9 send-email: fix style: cuddle 'elsif' and 'else' with closing braceEric Sunshine, May 31, 2015
  9. 5/9 send-email: refactor sendmail aliases parserEric Sunshine, May 31, 2015
  10. 6/9 send-email: simplify sendmail aliases comment and blank line recognizerEric Sunshine, May 31, 2015
  11. Eric SunshineJun 1, 2015
  12. 7/9 send-email: implement sendmail aliases line continuation supportEric Sunshine, May 31, 2015
  13. 8/9 t9001: refactor sendmail aliases test infrastructureEric Sunshine, May 31, 2015
  14. 9/9 t9001: add sendmail aliases line continuation testsEric Sunshine, May 31, 2015
  15. Allen HubbeJun 1, 2015

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.