[PATCH] send-email: support coloring dry-run output

Subsystems: the rest

DORMANTno replies

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] send-email: support coloring dry-run output

From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2016-06-15 22:53:50

It highlights sendmail command and subject lines. The most important
lines to me.

I'm no Perl expert. This patch is by no means for submission. But
maybe it'll motivate someone to do a proper patch.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
 git-send-email.perl |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index ef30c55..033ca5e 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1157,9 +1157,13 @@ X-Mailer: git-send-email $gitversion
 			    print "RCPT TO:<$entry>\n";
 			}
 		} else {
+			print color 'yellow';
 			print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n";
+			print color 'reset';
 		}
-		print $header, "\n";
+		my $colored_header = $header;
+		$colored_header =~ s/^(Subject: .*)/color("bold").$1.color("reset")/em;
+		print $colored_header, "\n";
 		if ($smtp) {
 			print "Result: ", $smtp->code, ' ',
 				($smtp->message =~ /\n([^\n]+\n)$/s), "\n";
-- 
1.7.8.36.g69ee2

Re: [PATCH] send-email: support coloring dry-run output

From: Angus Hammond <hidden>
Date: 2016-06-15 22:53:50

This seems like it would be a useful patch for those of us using sendmail.
I'll admit I don't know any perl at all, but one bit seems a little
odd to me. Is there a reason you use 3 separate print statements to
deal with the colours on the Sendmail line, but a regex substitution
the second time? I have no idea which would be considered the better
practice but surely we should pick one and be consistent? Unless
there's some difference between the two that I'm missing.
Thanks
Angus

Re: [PATCH] send-email: support coloring dry-run output

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:53:50

On Thu, May 17, 2012 at 9:27 PM, Angus Hammond [off-list ref] wrote:
This seems like it would be a useful patch for those of us using sendmail.
I'll admit I don't know any perl at all, but one bit seems a little
odd to me. Is there a reason you use 3 separate print statements to
deal with the colours on the Sendmail line, but a regex substitution
the second time? I have no idea which would be considered the better
practice but surely we should pick one and be consistent? Unless
there's some difference between the two that I'm missing.
No reasons. It was what I had in mind at that time and it worked, so I
did not bother cleaning up or anything.
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help