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

[PATCH] send-email: improve recipients_cmd()

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 27, 2013, 22:26 UTC
Message-ID
<1367101561-14671-1-git-send-email-felipe.contreras@gmail.com>

We don't need to quote the filename to pass to the command, we can use an array of all the arguments to pass to the command, which is safer, and more extensible.

Commit a47eab0 (send-email: use the three-arg form of open in recipients_cmd) stated we couldn't pass $file directly, but in fact, we can, the multi-word string is passed as is, and we can pass an array too.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 git-send-email.perl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index bd13cc8..7880d12 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1452,11 +1452,11 @@ foreach my $t (@files) {
 # Execute a command (e.g. $to_cmd) to get a list of email addresses
 # and return a results array
 sub recipients_cmd {
-	my ($prefix, $what, $cmd, $file) = @_;
+	my ($prefix, $what, $cmd, @args) = @_;
 
 	my $sanitized_sender = sanitize_address($sender);
 	my @addresses = ();
-	open my $fh, "-|", "$cmd \Q$file\E"
+	open my $fh, "-|", $cmd, @args
 	    or die "($prefix) Could not execute '$cmd'";
 	while (my $address = <$fh>) {
 		$address =~ s/^\s*//g;
-- 
1.8.2.1.1031.g2ee5873
Next: Junio C Hamano
Message 1 of 6 in “send-email: improve recipients_cmd()”
  1. send-email: improve recipients_cmd()Felipe Contreras, Apr 27, 2013
  2. Junio C HamanoApr 28, 2013
  3. Felipe ContrerasApr 29, 2013
  4. Junio C HamanoApr 29, 2013
  5. Felipe ContrerasApr 29, 2013
  6. Junio C HamanoApr 29, 2013

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.