@@ -139,9 +139,6 @@ sub format_2822_time {
139
139
my $smtp ;
140
140
my $auth ;
141
141
142
- sub unique_email_list (@);
143
- sub cleanup_compose_files ();
144
-
145
142
# Variables we fill in automatically, or via prompting:
146
143
my (@to ,$no_to ,@initial_to ,@cc ,$no_cc ,@initial_cc ,@bcclist ,$no_bcc ,@xh ,
147
144
$initial_reply_to ,$initial_subject ,@files ,
@@ -377,7 +374,7 @@ sub read_config {
377
374
if (@suppress_cc ) {
378
375
foreach my $entry (@suppress_cc ) {
379
376
die " Unknown --suppress-cc field: '$entry '\n "
380
- unless $entry =~ / ^(all|cccmd|cc|author|self|sob|body|bodycc)$ / ;
377
+ unless $entry =~ / ^(?: all|cccmd|cc|author|self|sob|body|bodycc)$ / ;
381
378
$suppress_cc {$entry } = 1;
382
379
}
383
380
}
@@ -521,12 +518,12 @@ ($)
521
518
push @rev_list_opts , " --" , @ARGV ;
522
519
@ARGV = ();
523
520
} elsif (-d $f and !check_file_rev_conflict($f )) {
524
- opendir (DH, $f )
521
+ opendir my $dh , $f
525
522
or die " Failed to opendir $f : $! " ;
526
523
527
524
push @files , grep { -f $_ } map { catfile($f , $_ ) }
528
- sort readdir (DH) ;
529
- closedir (DH) ;
525
+ sort readdir $dh ;
526
+ closedir $dh ;
530
527
} elsif ((-f $f or -p $f ) and !check_file_rev_conflict($f )) {
531
528
push @files , $f ;
532
529
} else {
558
555
usage();
559
556
}
560
557
561
- sub get_patch_subject ($) {
558
+ sub get_patch_subject {
562
559
my $fn = shift ;
563
560
open (my $fh , ' <' , $fn );
564
561
while (my $line = <$fh >) {
@@ -576,15 +573,15 @@ ($)
576
573
$compose_filename = ($repo ?
577
574
tempfile(" .gitsendemail.msg.XXXXXX" , DIR => $repo -> repo_path()) :
578
575
tempfile(" .gitsendemail.msg.XXXXXX" , DIR => " ." ))[1];
579
- open (C, " >" ,$compose_filename )
576
+ open my $c , " >" , $compose_filename
580
577
or die " Failed to open for writing $compose_filename : $! " ;
581
578
582
579
583
580
my $tpl_sender = $sender || $repoauthor || $repocommitter || ' ' ;
584
581
my $tpl_subject = $initial_subject || ' ' ;
585
582
my $tpl_reply_to = $initial_reply_to || ' ' ;
586
583
587
- print C <<EOT ;
584
+ print $c <<EOT ;
588
585
From $tpl_sender # This line is ignored.
589
586
GIT: Lines beginning in "GIT:" will be removed.
590
587
GIT: Consider including an overall diffstat or table of contents
@@ -597,33 +594,33 @@ ($)
597
594
598
595
EOT
599
596
for my $f (@files ) {
600
- print C get_patch_subject($f );
597
+ print $c get_patch_subject($f );
601
598
}
602
- close (C) ;
599
+ close $c ;
603
600
604
601
if ($annotate ) {
605
602
do_edit($compose_filename , @files );
606
603
} else {
607
604
do_edit($compose_filename );
608
605
}
609
606
610
- open (C2, " >" ,$compose_filename . " .final" )
607
+ open my $c2 , " >" , $compose_filename . " .final"
611
608
or die " Failed to open $compose_filename .final : " . $! ;
612
609
613
- open (C, " <" ,$compose_filename )
610
+ open $c , " <" , $compose_filename
614
611
or die " Failed to open $compose_filename : " . $! ;
615
612
616
613
my $need_8bit_cte = file_has_nonascii($compose_filename );
617
614
my $in_body = 0;
618
615
my $summary_empty = 1;
619
- while (<C >) {
616
+ while (<$c >) {
620
617
next if m / ^GIT:/ ;
621
618
if ($in_body ) {
622
619
$summary_empty = 0 unless (/ ^\n $ / );
623
620
} elsif (/ ^\n $ / ) {
624
621
$in_body = 1;
625
622
if ($need_8bit_cte ) {
626
- print C2 " MIME-Version: 1.0\n " ,
623
+ print $c2 " MIME-Version: 1.0\n " ,
627
624
" Content-Type: text/plain; " ,
628
625
" charset=UTF-8\n " ,
629
626
" Content-Transfer-Encoding: 8bit\n " ;
@@ -648,10 +645,10 @@ ($)
648
645
print " To/Cc/Bcc fields are not interpreted yet, they have been ignored\n " ;
649
646
next ;
650
647
}
651
- print C2 $_ ;
648
+ print $c2 $_ ;
652
649
}
653
- close (C) ;
654
- close (C2) ;
650
+ close $c ;
651
+ close $c2 ;
655
652
656
653
if ($summary_empty ) {
657
654
print " Summary email is empty, skipping it\n " ;
@@ -688,7 +685,7 @@ sub ask {
688
685
689
686
my %broken_encoding ;
690
687
691
- sub file_declares_8bit_cte ($) {
688
+ sub file_declares_8bit_cte {
692
689
my $fn = shift ;
693
690
open (my $fh , ' <' , $fn );
694
691
while (my $line = <$fh >) {
717
714
718
715
if (!$force ) {
719
716
for my $f (@files ) {
720
- if (get_patch_subject($f ) =~ / \*\*\ * SUBJECT HERE \*\*\* / ) {
717
+ if (get_patch_subject($f ) =~ / \Q ** * SUBJECT HERE *** \E / ) {
721
718
die " Refusing to send because the patch\n\t $f \n "
722
719
. " has the template subject '*** SUBJECT HERE ***'. "
723
720
. " Pass --force if you really want to send.\n " ;
@@ -789,8 +786,8 @@ sub expand_one_alias {
789
786
790
787
sub extract_valid_address {
791
788
my $address = shift ;
792
- my $local_part_regexp = ' [^<>"\s@]+' ;
793
- my $domain_regexp = ' [^.<>"\s@]+(?:\.[^.<>"\s@]+)+' ;
789
+ my $local_part_regexp = qr / [^<>"\s @]+/ ;
790
+ my $domain_regexp = qr / [^.<>"\s @]+(?:\. [^.<>"\s @]+)+/ ;
794
791
795
792
# check for a local address:
796
793
return $address if ($address =~ / ^($local_part_regexp )$ / );
@@ -831,7 +828,7 @@ sub make_message_id {
831
828
last if (defined $du_part and $du_part ne ' ' );
832
829
}
833
830
if (not defined $du_part or $du_part eq ' ' ) {
834
- use Sys::Hostname qw( ) ;
831
+ require Sys::Hostname;
835
832
$du_part = ' user@' . Sys::Hostname::hostname();
836
833
}
837
834
my $message_id_template = " <%s -git-send-email-%s >" ;
@@ -864,8 +861,8 @@ sub quote_rfc2047 {
864
861
865
862
sub is_rfc2047_quoted {
866
863
my $s = shift ;
867
- my $token = ' [^][()<>@,;:"\/?.= \000-\037\177-\377]+' ;
868
- my $encoded_text = ' [!->@-~]+' ;
864
+ my $token = qr / [^][()<>@,;:"\/ ?.= \000 -\037\177 -\377 ]+/ ;
865
+ my $encoded_text = qr / [!->@-~]+/ ;
869
866
length ($s ) <= 75 &&
870
867
$s =~ m / ^(?:"[[:ascii:]]*"|=\? $token \? $token \? $encoded_text \? =)$ / o ;
871
868
}
@@ -876,7 +873,7 @@ sub sanitize_address {
876
873
my ($recipient_name , $recipient_addr ) = ($recipient =~ / ^(.*?)\s *(<.*)/ );
877
874
878
875
if (not $recipient_name ) {
879
- return " $recipient " ;
876
+ return $recipient ;
880
877
}
881
878
882
879
# if recipient_name is already quoted, do nothing
@@ -893,7 +890,7 @@ sub sanitize_address {
893
890
# double quotes are needed if specials or CTLs are included
894
891
elsif ($recipient_name =~ / [][()<>@,;:\\ ".\000 -\037\177 ]/ ) {
895
892
$recipient_name =~ s / (["\\\r ])/ \\ $1 / g ;
896
- $recipient_name = " \" $recipient_name \" " ;
893
+ $recipient_name = qq[ " $recipient_name " ] ;
897
894
}
898
895
899
896
return " $recipient_name $recipient_addr " ;
@@ -1049,7 +1046,7 @@ sub send_message {
1049
1046
exec ($smtp_server , @sendmail_parameters ) or die $! ;
1050
1047
}
1051
1048
print $sm " $header \n $message " ;
1052
- close $sm or die $? ;
1049
+ close $sm or die $! ;
1053
1050
} else {
1054
1051
1055
1052
if (!defined $smtp_server ) {
@@ -1155,7 +1152,7 @@ sub send_message {
1155
1152
$message_num = 0;
1156
1153
1157
1154
foreach my $t (@files ) {
1158
- open (F, " <" ,$t ) or die " can't open file $t " ;
1155
+ open my $fh , " <" , $t or die " can't open file $t " ;
1159
1156
1160
1157
my $author = undef ;
1161
1158
my $author_encoding ;
@@ -1169,7 +1166,7 @@ sub send_message {
1169
1166
$message = " " ;
1170
1167
$message_num ++;
1171
1168
# First unfold multiline header fields
1172
- while (<F >) {
1169
+ while (<$fh >) {
1173
1170
last if / ^\s *$ / ;
1174
1171
if (/ ^\s +\S / and @header ) {
1175
1172
chomp ($header [$#header ]);
@@ -1252,7 +1249,7 @@ sub send_message {
1252
1249
}
1253
1250
}
1254
1251
# Now parse the message body
1255
- while (<F >) {
1252
+ while (<$fh >) {
1256
1253
$message .= $_ ;
1257
1254
if (/ ^(Signed-off-by|Cc): (.*)$ /i ) {
1258
1255
chomp ;
@@ -1269,7 +1266,7 @@ sub send_message {
1269
1266
$c , $_ ) unless $quiet ;
1270
1267
}
1271
1268
}
1272
- close F ;
1269
+ close $fh ;
1273
1270
1274
1271
push @to , recipients_cmd(" to-cmd" , " to" , $to_cmd , $t )
1275
1272
if defined $to_cmd ;
@@ -1340,10 +1337,9 @@ sub recipients_cmd {
1340
1337
1341
1338
my $sanitized_sender = sanitize_address($sender );
1342
1339
my @addresses = ();
1343
- open (F , " $cmd \Q $file \E |" )
1340
+ open my $fh , " $cmd \Q $file \E |"
1344
1341
or die " ($prefix ) Could not execute '$cmd '" ;
1345
- while (<F>) {
1346
- my $address = $_ ;
1342
+ while (my $address = <$fh >) {
1347
1343
$address =~ s / ^\s *// g ;
1348
1344
$address =~ s /\s *$// g ;
1349
1345
$address = sanitize_address($address );
@@ -1352,20 +1348,20 @@ sub recipients_cmd {
1352
1348
printf (" ($prefix ) Adding %s : %s from: '%s '\n " ,
1353
1349
$what , $address , $cmd ) unless $quiet ;
1354
1350
}
1355
- close F
1351
+ close $fh
1356
1352
or die " ($prefix ) failed to close pipe to '$cmd '" ;
1357
1353
return @addresses ;
1358
1354
}
1359
1355
1360
1356
cleanup_compose_files();
1361
1357
1362
- sub cleanup_compose_files () {
1358
+ sub cleanup_compose_files {
1363
1359
unlink ($compose_filename , $compose_filename . " .final" ) if $compose ;
1364
1360
}
1365
1361
1366
1362
$smtp -> quit if $smtp ;
1367
1363
1368
- sub unique_email_list (@) {
1364
+ sub unique_email_list {
1369
1365
my %seen ;
1370
1366
my @emails ;
1371
1367
0 commit comments