git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Klink <flokli@flokli.de>
To: git@vger.kernel.org
Cc: flokli@flokli.de, sandals@crustytoothpaste.net, gitster@pobox.com
Subject: [PATCH v3] git-send-email: honor $PATH for sendmail binary
Date: Tue, 28 Nov 2017 01:49:04 +0100	[thread overview]
Message-ID: <20171128004904.13978-1-flokli@flokli.de> (raw)
In-Reply-To: <20171119123511.pck5aqak4yyc6367@tp.flokli.de>

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>
---
 Documentation/git-send-email.txt | 6 +++---
 git-send-email.perl              | 4 +++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index bac9014ac..44db25567 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -203,9 +203,9 @@ a password is obtained using 'git-credential'.
 	specify a full pathname of a sendmail-like program instead;
 	the program must support the `-i` option.  Default value can
 	be specified by the `sendemail.smtpServer` configuration
-	option; the built-in default is `/usr/sbin/sendmail` or
-	`/usr/lib/sendmail` if such program is available, or
-	`localhost` otherwise.
+	option; the built-in default is to search for `sendmail` in
+	`/usr/sbin`, `/usr/lib/sendmail` and $PATH if such program is
+	available, falling back to `localhost` otherwise.
 
 --smtp-server-port=<port>::
 	Specifies a port different from the default port (SMTP
diff --git a/git-send-email.perl b/git-send-email.perl
index 2208dcc21..edcc6d346 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -885,7 +885,9 @@ if (defined $initial_reply_to) {
 }
 
 if (!defined $smtp_server) {
-	foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {
+	my @sendmail_paths = qw( /usr/sbin/sendmail /usr/lib/sendmail );
+	push @sendmail_paths, map {"$_/sendmail"} split /:/, $ENV{PATH};
+	foreach (@sendmail_paths) {
 		if (-x $_) {
 			$smtp_server = $_;
 			last;
-- 
2.15.0


  parent reply	other threads:[~2017-11-28  0:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-18 12:42 [PATCH] git-send-email: honor $PATH Florian Klink
2017-11-18 21:01 ` brian m. carlson
2017-11-18 21:28   ` Florian Klink
2017-11-18 22:20     ` [PATCH v2] git-send-email: honor $PATH for sendmail binary Florian Klink
2017-11-19  1:04   ` [PATCH] git-send-email: honor $PATH Junio C Hamano
2017-11-19 12:35     ` Florian Klink
2017-11-28  0:32       ` Florian Klink
2017-11-28  0:49       ` Florian Klink [this message]
2017-11-28  1:13         ` [PATCH v3] git-send-email: honor $PATH for sendmail binary Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171128004904.13978-1-flokli@flokli.de \
    --to=flokli@flokli.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sandals@crustytoothpaste.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).