git-send-email: honor $PATH for sendmail binary
This extends git-send-email to also consider sendmail binaries in $PATH after checking the (fixed) list of /usr/sbin and /usr/lib, and before falling back to localhost. Signed-off-by: Florian Klink <flokli@flokli.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Florian Klink committed
Nov 28, 2017 at 01:49 UTC
1ab2fd4f397d8891f5345f876d42ab360859bcca
2 files changed
+6
-4
Documentation/git-send-email.txt
+3
-3
@@ -203,9 +203,9 @@ a password is obtained using 'git-credential'.
203
specify a full pathname of a sendmail-like program instead;
204
the program must support the `-i` option. Default value can
205
be specified by the `sendemail.smtpServer` configuration
206
- option; the built-in default is `/usr/sbin/sendmail` or
207
- `/usr/lib/sendmail` if such program is available, or
208
- `localhost` otherwise.
206
+ option; the built-in default is to search for `sendmail` in
207
+ `/usr/sbin`, `/usr/lib` and $PATH if such program is
208
+ available, falling back to `localhost` otherwise.
209
210
--smtp-server-port=<port>::
211
Specifies a port different from the default port (SMTP
git-send-email.perl
+3
-1
@@ -885,7 +885,9 @@ if (defined $initial_reply_to) {
885
}
886
887
if (!defined $smtp_server) {
888
- foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {
888
+ my @sendmail_paths = qw( /usr/sbin/sendmail /usr/lib/sendmail );
889
+ push @sendmail_paths, map {"$_/sendmail"} split /:/, $ENV{PATH};
890
+ foreach (@sendmail_paths) {
891
if (-x $_) {
892
$smtp_server = $_;
893
last;