git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] git-send-email: use ! to indicate relative path to command

From
Gregory Anders <greg@gpanders.com>
Date
May 11, 2021, 19:01 UTC
Message-ID
<20210511190101.22128-1-greg@gpanders.com>

When the smtpServer config option is prefixed with a ! character, the value of the option should be interpreted as a command to look up on PATH. ---

Fix the implementation to correctly find the absolute path for the given command, and report an error if the command is not found on PATH.

 git-send-email.perl | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 175da07d94..6d10901595 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1492,7 +1492,24 @@ sub send_message {
 
 	if ($dry_run) {
 		# We don't want to send the email.
-	} elsif (file_name_is_absolute($smtp_server)) {
+	} elsif (file_name_is_absolute($smtp_server) || $smtp_server =~ /^!/) {
+		if ($smtp_server =~ s/^!//) {
+			my $smtp_command;
+			my @progs = map {"$_/$smtp_server"} split /:/, $ENV{PATH};
+			foreach (@progs) {
+				if (-x $_) {
+					$smtp_command = $_;
+					last;
+				}
+			}
+
+			if (!defined $smtp_command) {
+				die __("The command $smtp_server was not found on PATH.")
+			}
+
+			$smtp_server = $smtp_command;
+		}
+
 		my $pid = open my $sm, '|-';
 		defined $pid or die $!;
 		if (!$pid) {
-- 
2.31.1.576.g55f6e1c2f1
Message 1 of 1 in “git-send-email: use ! to indicate relative path to command”
  1. git-send-email: use ! to indicate relative path to commandGregory Anders, May 11, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.