Skip to content

Commit 41ae8f1

Browse files
avargitster
authored andcommitted
send-email: use Perl idioms in while loop
Change `while(<$fh>) { my $c = $_' to `while(my $c = <$fh>) {', and use `chomp $c' instead of `$c =~ s/\n$//g;', the two are equivalent in this case. I've also changed the --cccmd test so that we test for the stripping of whitespace at the beginning of the lines returned from the --cccmd. I think we probably shouldn't do this, but it was there already so I haven't changed the behavior. 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 529dd38 commit 41ae8f1

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

git-send-email.perl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,10 +1252,9 @@ sub send_message {
12521252
if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
12531253
open my $fh, "$cc_cmd \Q$t\E |"
12541254
or die "(cc-cmd) Could not execute '$cc_cmd'";
1255-
while(<$fh>) {
1256-
my $c = $_;
1255+
while(my $c = <$fh>) {
1256+
chomp $c;
12571257
$c =~ s/^\s*//g;
1258-
$c =~ s/\n$//g;
12591258
next if ($c eq $sender and $suppress_from);
12601259
push @cc, $c;
12611260
printf("(cc-cmd) Adding cc: %s from: '%s'\n",

t/t9001-send-email.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ test_expect_success $PREREQ 'Prompting works' '
204204
test_expect_success $PREREQ 'cccmd works' '
205205
clean_fake_sendmail &&
206206
cp $patches cccmd.patch &&
207-
echo [email protected] >>cccmd.patch &&
207+
echo "cccmd-- [email protected]" >>cccmd.patch &&
208208
{
209209
echo "#!$SHELL_PATH"
210210
echo sed -n -e s/^cccmd--//p \"\$1\"

0 commit comments

Comments
 (0)