Skip to content

Commit

Permalink
send-email: use lexical filehandles during sending
Browse files Browse the repository at this point in the history
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 fe0f944 commit f9237e6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ sub send_message {
$message_num = 0;

foreach my $t (@files) {
open(F,"<",$t) or die "can't open file $t";
open my $fh, "<", $t or die "can't open file $t";

my $author = undef;
my $author_encoding;
Expand All @@ -1157,7 +1157,7 @@ sub send_message {
$message = "";
$message_num++;
# First unfold multiline header fields
while(<F>) {
while(<$fh>) {
last if /^\s*$/;
if (/^\s+\S/ and @header) {
chomp($header[$#header]);
Expand Down Expand Up @@ -1233,7 +1233,7 @@ sub send_message {
}
}
# Now parse the message body
while(<F>) {
while(<$fh>) {
$message .= $_;
if (/^(Signed-off-by|Cc): (.*)$/i) {
chomp;
Expand All @@ -1250,12 +1250,12 @@ sub send_message {
$c, $_) unless $quiet;
}
}
close F;
close $fh;

if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
open(F, "$cc_cmd \Q$t\E |")
open my $fh, "$cc_cmd \Q$t\E |"
or die "(cc-cmd) Could not execute '$cc_cmd'";
while(<F>) {
while(<$fh>) {
my $c = $_;
$c =~ s/^\s*//g;
$c =~ s/\n$//g;
Expand All @@ -1264,7 +1264,7 @@ sub send_message {
printf("(cc-cmd) Adding cc: %s from: '%s'\n",
$c, $cc_cmd) unless $quiet;
}
close F
close $fh
or die "(cc-cmd) failed to close pipe to '$cc_cmd'";
}

Expand Down

0 comments on commit f9237e6

Please sign in to comment.