Skip to content

Commit 0b44946

Browse files
committed
Merge branch 'ef/send-email-absolute-path-to-the-command'
* ef/send-email-absolute-path-to-the-command: send-email: windows drive prefix (e.g. C:) appears only at the beginning send-email: recognize absolute path on Windows
2 parents 84241e7 + f24ecf5 commit 0b44946

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

git-send-email.perl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,18 @@ sub ssl_verify_params {
11131113
}
11141114
}
11151115

1116+
sub file_name_is_absolute {
1117+
my ($path) = @_;
1118+
1119+
# msys does not grok DOS drive-prefixes
1120+
if ($^O eq 'msys') {
1121+
return ($path =~ m#^/# || $path =~ m#^[a-zA-Z]\:#)
1122+
}
1123+
1124+
require File::Spec::Functions;
1125+
return File::Spec::Functions::file_name_is_absolute($path);
1126+
}
1127+
11161128
# Returns 1 if the message was sent, and 0 otherwise.
11171129
# In actuality, the whole program dies when there
11181130
# is an error sending a message.
@@ -1197,7 +1209,7 @@ sub send_message {
11971209

11981210
if ($dry_run) {
11991211
# We don't want to send the email.
1200-
} elsif ($smtp_server =~ m#^/#) {
1212+
} elsif (file_name_is_absolute($smtp_server)) {
12011213
my $pid = open my $sm, '|-';
12021214
defined $pid or die $!;
12031215
if (!$pid) {
@@ -1271,7 +1283,7 @@ sub send_message {
12711283
printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
12721284
} else {
12731285
print (($dry_run ? "Dry-" : "")."OK. Log says:\n");
1274-
if ($smtp_server !~ m#^/#) {
1286+
if (!file_name_is_absolute($smtp_server)) {
12751287
print "Server: $smtp_server\n";
12761288
print "MAIL FROM:<$raw_from>\n";
12771289
foreach my $entry (@recipients) {

0 commit comments

Comments
 (0)