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

3 messages from 2012-05-17 to 2012-05-18. Participants: Nguyễn Thái Ngọc Duy, Angus Hammond, Nguyen Thai Ngoc Duy.
Thread: https://gitlist.dev/t/30547

## Nguyễn Thái Ngọc Duy, 2012-05-17 13:16

Subject: [PATCH] send-email: support coloring dry-run output
Message-ID: <1337260596-15498-1-git-send-email-pclouds@gmail.com>
URL: https://gitlist.dev/e/1337260596-15498-1-git-send-email-pclouds%40gmail.com

```
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 <pclouds@gmail.com>
---
 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

```

## Angus Hammond, 2012-05-17 14:27

Subject: Re: [PATCH] send-email: support coloring dry-run output
Message-ID: <CAOBOgRaEnFOJ9=ZHczAq_TNerrrMciG8g0SHYDiKrqfhASU-iA@mail.gmail.com>
URL: https://gitlist.dev/e/CAOBOgRaEnFOJ9%3DZHczAq_TNerrrMciG8g0SHYDiKrqfhASU-iA%40mail.gmail.com
In-Reply-To: <1337260596-15498-1-git-send-email-pclouds@gmail.com>

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

```

## Nguyen Thai Ngoc Duy, 2012-05-18 04:26

Subject: Re: [PATCH] send-email: support coloring dry-run output
Message-ID: <CACsJy8D=O81cFu0X1g7J++bBaadObkfJ2rsV_WUfDpVrEYotTA@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8D%3DO81cFu0X1g7J%2B%2BbBaadObkfJ2rsV_WUfDpVrEYotTA%40mail.gmail.com
In-Reply-To: <CAOBOgRaEnFOJ9=ZHczAq_TNerrrMciG8g0SHYDiKrqfhASU-iA@mail.gmail.com>

```
On Thu, May 17, 2012 at 9:27 PM, Angus Hammond <angusgh@gmail.com> 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

```
