]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-send-email.perl
send-email: use Perl idioms in while loop
[thirdparty/git.git] / git-send-email.perl
index ce9b5ebd4040e17156ed66baeb34ed6ecdd082a9..036e4b4259babdda1e76a5aa558c3600b43a89c0 100755 (executable)
@@ -365,7 +365,7 @@ my(%suppress_cc);
 if (@suppress_cc) {
        foreach my $entry (@suppress_cc) {
                die "Unknown --suppress-cc field: '$entry'\n"
-                       unless $entry =~ /^(all|cccmd|cc|author|self|sob|body|bodycc)$/;
+                       unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc)$/;
                $suppress_cc{$entry} = 1;
        }
 }
@@ -705,7 +705,7 @@ if (!defined $auto_8bit_encoding && scalar %broken_encoding) {
 
 if (!$force) {
        for my $f (@files) {
-               if (get_patch_subject($f) =~ /\*\*\* SUBJECT HERE \*\*\*/) {
+               if (get_patch_subject($f) =~ /\Q*** SUBJECT HERE ***\E/) {
                        die "Refusing to send because the patch\n\t$f\n"
                                . "has the template subject '*** SUBJECT HERE ***'. "
                                . "Pass --force if you really want to send.\n";
@@ -819,7 +819,7 @@ sub make_message_id {
                last if (defined $du_part and $du_part ne '');
        }
        if (not defined $du_part or $du_part eq '') {
-               use Sys::Hostname qw();
+               require Sys::Hostname;
                $du_part = 'user@' . Sys::Hostname::hostname();
        }
        my $message_id_template = "<%s-git-send-email-%s>";
@@ -864,7 +864,7 @@ sub sanitize_address {
        my ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)\s*(<.*)/);
 
        if (not $recipient_name) {
-               return "$recipient";
+               return $recipient;
        }
 
        # if recipient_name is already quoted, do nothing
@@ -881,7 +881,7 @@ sub sanitize_address {
        # double quotes are needed if specials or CTLs are included
        elsif ($recipient_name =~ /[][()<>@,;:\\".\000-\037\177]/) {
                $recipient_name =~ s/(["\\\r])/\\$1/g;
-               $recipient_name = "\"$recipient_name\"";
+               $recipient_name = qq["$recipient_name"];
        }
 
        return "$recipient_name $recipient_addr";
@@ -1035,7 +1035,7 @@ X-Mailer: git-send-email $gitversion
                        exec($smtp_server, @sendmail_parameters) or die $!;
                }
                print $sm "$header\n$message";
-               close $sm or die $?;
+               close $sm or die $!;
        } else {
 
                if (!defined $smtp_server) {
@@ -1252,10 +1252,9 @@ foreach my $t (@files) {
        if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
                open my $fh, "$cc_cmd \Q$t\E |"
                        or die "(cc-cmd) Could not execute '$cc_cmd'";
-               while(<$fh>) {
-                       my $c = $_;
+               while(my $c = <$fh>) {
+                       chomp $c;
                        $c =~ s/^\s*//g;
-                       $c =~ s/\n$//g;
                        next if ($c eq $sender and $suppress_from);
                        push @cc, $c;
                        printf("(cc-cmd) Adding cc: %s from: '%s'\n",