send-email: use lexical filehandles during sending
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:42 UTC
f9237e61576c9bd1ba6a00276a9a849a4b5354fb
1 file changed
+7
-7
git-send-email.perl
+7
-7
@@ -1144,7 +1144,7 @@ $subject = $initial_subject;
1144
$message_num = 0;
1145
1146
foreach my $t (@files) {
1147
- open(F,"<",$t) or die "can't open file $t";
1147
+ open my $fh, "<", $t or die "can't open file $t";
1148
1149
my $author = undef;
1150
my $author_encoding;
@@ -1157,7 +1157,7 @@ foreach my $t (@files) {
1157
$message = "";
1158
$message_num++;
1159
# First unfold multiline header fields
1160
- while(<F>) {
1160
+ while(<$fh>) {
1161
last if /^\s*$/;
1162
if (/^\s+\S/ and @header) {
1163
chomp($header[$#header]);
@@ -1233,7 +1233,7 @@ foreach my $t (@files) {
1233
}
1234
}
1235
# Now parse the message body
1236
- while(<F>) {
1236
+ while(<$fh>) {
1237
$message .= $_;
1238
if (/^(Signed-off-by|Cc): (.*)$/i) {
1239
chomp;
@@ -1250,12 +1250,12 @@ foreach my $t (@files) {
1250
$c, $_) unless $quiet;
1251
}
1252
}
1253
- close F;
1253
+ close $fh;
1254
1255
if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
1256
- open(F, "$cc_cmd \Q$t\E |")
1256
+ open my $fh, "$cc_cmd \Q$t\E |"
1257
or die "(cc-cmd) Could not execute '$cc_cmd'";
1258
- while(<F>) {
1258
+ while(<$fh>) {
1259
my $c = $_;
1260
$c =~ s/^\s*//g;
1261
$c =~ s/\n$//g;
@@ -1264,7 +1264,7 @@ foreach my $t (@files) {
1264
printf("(cc-cmd) Adding cc: %s from: '%s'\n",
1265
$c, $cc_cmd) unless $quiet;
1266
}
1267
- close F
1267
+ close $fh
1268
or die "(cc-cmd) failed to close pipe to '$cc_cmd'";
1269
}
1270