Skip to content

Commit

Permalink
send-email: use Perl idioms in while loop
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ævar Arnfjörð Bjarmason authored and Junio C Hamano committed Sep 30, 2010
1 parent 529dd38 commit 41ae8f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -1252,10 +1252,9 @@ sub send_message {
if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
open my $fh, "$cc_cmd \Q$t\E |"
or die "(cc-cmd) Could not execute '$cc_cmd'";
while(<$fh>) {
my $c = $_;
while(my $c = <$fh>) {
chomp $c;
$c =~ s/^\s*//g;
$c =~ s/\n$//g;
next if ($c eq $sender and $suppress_from);
push @cc, $c;
printf("(cc-cmd) Adding cc: %s from: '%s'\n",
Expand Down
2 changes: 1 addition & 1 deletion t/t9001-send-email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ test_expect_success $PREREQ 'Prompting works' '
test_expect_success $PREREQ 'cccmd works' '
clean_fake_sendmail &&
cp $patches cccmd.patch &&
echo cccmd--cccmd@example.com >>cccmd.patch &&
echo "cccmd-- cccmd@example.com" >>cccmd.patch &&
{
echo "#!$SHELL_PATH"
echo sed -n -e s/^cccmd--//p \"\$1\"
Expand Down

0 comments on commit 41ae8f1

Please sign in to comment.