@@ -1502,16 +1502,7 @@ sub file_name_is_absolute {
1502
1502
return File::Spec::Functions::file_name_is_absolute($path );
1503
1503
}
1504
1504
1505
- # Prepares the email, then asks the user what to do.
1506
- #
1507
- # If the user chooses to send the email, it's sent and 1 is returned.
1508
- # If the user chooses not to send the email, 0 is returned.
1509
- # If the user decides they want to make further edits, -1 is returned and the
1510
- # caller is expected to call send_message again after the edits are performed.
1511
- #
1512
- # If an error occurs sending the email, this just dies.
1513
-
1514
- sub send_message {
1505
+ sub gen_header {
1515
1506
my @recipients = unique_email_list(@to );
1516
1507
@cc = (grep { my $cc = extract_valid_address_or_die($_ );
1517
1508
not grep { $cc eq $_ || $_ =~ / <\Q ${cc} \E >$ / } @recipients
@@ -1553,6 +1544,22 @@ sub send_message {
1553
1544
if (@xh ) {
1554
1545
$header .= join (" \n " , @xh ) . " \n " ;
1555
1546
}
1547
+ my $recipients_ref = \@recipients ;
1548
+ return ($recipients_ref , $to , $date , $gitversion , $cc , $ccline , $header );
1549
+ }
1550
+
1551
+ # Prepares the email, then asks the user what to do.
1552
+ #
1553
+ # If the user chooses to send the email, it's sent and 1 is returned.
1554
+ # If the user chooses not to send the email, 0 is returned.
1555
+ # If the user decides they want to make further edits, -1 is returned and the
1556
+ # caller is expected to call send_message again after the edits are performed.
1557
+ #
1558
+ # If an error occurs sending the email, this just dies.
1559
+
1560
+ sub send_message {
1561
+ my ($recipients_ref , $to , $date , $gitversion , $cc , $ccline , $header ) = gen_header();
1562
+ my @recipients = @$recipients_ref ;
1556
1563
1557
1564
my @sendmail_parameters = (' -i' , @recipients );
1558
1565
my $raw_from = $sender ;
@@ -1742,11 +1749,8 @@ sub send_message {
1742
1749
$references = $initial_in_reply_to || ' ' ;
1743
1750
$message_num = 0;
1744
1751
1745
- # Prepares the email, prompts the user, sends it out
1746
- # Returns 0 if an edit was done and the function should be called again, or 1
1747
- # otherwise.
1748
- sub process_file {
1749
- my ($t ) = @_ ;
1752
+ sub pre_process_file {
1753
+ my ($t , $quiet ) = @_ ;
1750
1754
1751
1755
open my $fh , " <" , $t or die sprintf (__(" can't open file %s " ), $t );
1752
1756
@@ -1900,9 +1904,9 @@ sub process_file {
1900
1904
}
1901
1905
close $fh ;
1902
1906
1903
- push @to , recipients_cmd(" to-cmd" , " to" , $to_cmd , $t )
1907
+ push @to , recipients_cmd(" to-cmd" , " to" , $to_cmd , $t , $quiet )
1904
1908
if defined $to_cmd ;
1905
- push @cc , recipients_cmd(" cc-cmd" , " cc" , $cc_cmd , $t )
1909
+ push @cc , recipients_cmd(" cc-cmd" , " cc" , $cc_cmd , $t , $quiet )
1906
1910
if defined $cc_cmd && !$suppress_cc {' cccmd' };
1907
1911
1908
1912
if ($broken_encoding {$t } && !$has_content_type ) {
@@ -1961,6 +1965,15 @@ sub process_file {
1961
1965
@initial_to = @to ;
1962
1966
}
1963
1967
}
1968
+ }
1969
+
1970
+ # Prepares the email, prompts the user, and sends it out
1971
+ # Returns 0 if an edit was done and the function should be called again, or 1
1972
+ # on the email being successfully sent out.
1973
+ sub process_file {
1974
+ my ($t ) = @_ ;
1975
+
1976
+ pre_process_file($t , $quiet );
1964
1977
1965
1978
my $message_was_sent = send_message();
1966
1979
if ($message_was_sent == -1) {
@@ -2009,7 +2022,7 @@ sub process_file {
2009
2022
# Execute a command (e.g. $to_cmd) to get a list of email addresses
2010
2023
# and return a results array
2011
2024
sub recipients_cmd {
2012
- my ($prefix , $what , $cmd , $file ) = @_ ;
2025
+ my ($prefix , $what , $cmd , $file , $quiet ) = @_ ;
2013
2026
2014
2027
my @addresses = ();
2015
2028
open my $fh , " -|" , " $cmd \Q $file \E "
0 commit comments