Skip to content

Commit fe0f944

Browse files
avargitster
authored andcommitted
send-email: use lexical filehandles for $compose
Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]: Avery Pennarun <[email protected]> Reviewed-by: Jeff King <[email protected]> > Signed-off-by: Junio C Hamano <[email protected]>
1 parent c603816 commit fe0f944

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

git-send-email.perl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -567,15 +567,15 @@ ($)
567567
$compose_filename = ($repo ?
568568
tempfile(".gitsendemail.msg.XXXXXX", DIR => $repo->repo_path()) :
569569
tempfile(".gitsendemail.msg.XXXXXX", DIR => "."))[1];
570-
open(C,">",$compose_filename)
570+
open my $c, ">", $compose_filename
571571
or die "Failed to open for writing $compose_filename: $!";
572572

573573

574574
my $tpl_sender = $sender || $repoauthor || $repocommitter || '';
575575
my $tpl_subject = $initial_subject || '';
576576
my $tpl_reply_to = $initial_reply_to || '';
577577

578-
print C <<EOT;
578+
print $c <<EOT;
579579
From $tpl_sender # This line is ignored.
580580
GIT: Lines beginning in "GIT:" will be removed.
581581
GIT: Consider including an overall diffstat or table of contents
@@ -588,33 +588,33 @@ ($)
588588
589589
EOT
590590
for my $f (@files) {
591-
print C get_patch_subject($f);
591+
print $c get_patch_subject($f);
592592
}
593-
close(C);
593+
close $c;
594594

595595
if ($annotate) {
596596
do_edit($compose_filename, @files);
597597
} else {
598598
do_edit($compose_filename);
599599
}
600600

601-
open(C2,">",$compose_filename . ".final")
601+
open my $c2, ">", $compose_filename . ".final"
602602
or die "Failed to open $compose_filename.final : " . $!;
603603

604-
open(C,"<",$compose_filename)
604+
open $c, "<", $compose_filename
605605
or die "Failed to open $compose_filename : " . $!;
606606

607607
my $need_8bit_cte = file_has_nonascii($compose_filename);
608608
my $in_body = 0;
609609
my $summary_empty = 1;
610-
while(<C>) {
610+
while(<$c>) {
611611
next if m/^GIT:/;
612612
if ($in_body) {
613613
$summary_empty = 0 unless (/^\n$/);
614614
} elsif (/^\n$/) {
615615
$in_body = 1;
616616
if ($need_8bit_cte) {
617-
print C2 "MIME-Version: 1.0\n",
617+
print $c2 "MIME-Version: 1.0\n",
618618
"Content-Type: text/plain; ",
619619
"charset=UTF-8\n",
620620
"Content-Transfer-Encoding: 8bit\n";
@@ -639,10 +639,10 @@ ($)
639639
print "To/Cc/Bcc fields are not interpreted yet, they have been ignored\n";
640640
next;
641641
}
642-
print C2 $_;
642+
print $c2 $_;
643643
}
644-
close(C);
645-
close(C2);
644+
close $c;
645+
close $c2;
646646

647647
if ($summary_empty) {
648648
print "Summary email is empty, skipping it\n";

0 commit comments

Comments
 (0)