@matheusbsbs / matheus-bagliano / commits / 41ae8f1d6c
Fork 0

send-email: use Perl idioms in while loop

Change `while(<$fh>) { my $c = $_' to `while(my $c = <$fh>) {', and use `chomp $c' instead of `$c =~ s/\n$//g;', the two are equivalent in this case. I've also changed the --cccmd test so that we test for the stripping of whitespace at the beginning of the lines returned from the --cccmd. I think we probably shouldn't do this, but it was there already so I haven't changed the behavior. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.comReviewed-by: Avery Pennarun <apenwarr@gmail.com> Reviewed-by: Jeff King <peff@peff.net> > Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Sep 30, 2010 at 13:43 UTC 41ae8f1d6cf70f32328c984cdbe51d0f156cd501
2 files changed +3 -4
git-send-email.perl
+2 -3
@@ -1252,10 +1252,9 @@ foreach my $t (@files) {
1252 if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
1253 open my $fh, "$cc_cmd \Q$t\E |"
1254 or die "(cc-cmd) Could not execute '$cc_cmd'";
1255 - while(<$fh>) {
1256 - my $c = $_;
1255 + while(my $c = <$fh>) {
1256 + chomp $c;
1257 $c =~ s/^\s*//g;
1258 - $c =~ s/\n$//g;
1258 next if ($c eq $sender and $suppress_from);
1259 push @cc, $c;
1260 printf("(cc-cmd) Adding cc: %s from: '%s'\n",
t/t9001-send-email.sh
+1 -1
@@ -204,7 +204,7 @@ test_expect_success $PREREQ 'Prompting works' '
204 test_expect_success $PREREQ 'cccmd works' '
205 clean_fake_sendmail &&
206 cp $patches cccmd.patch &&
207 - echo cccmd--cccmd@example.com >>cccmd.patch &&
207 + echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
208 {
209 echo "#!$SHELL_PATH"
210 echo sed -n -e s/^cccmd--//p \"\$1\"