send-email: use the three-arg form of open in recipients_cmd
authorRamkumar Ramachandra <artagnon@gmail.com>
Mon, 1 Apr 2013 01:40:42 +0000 (18:40 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2013 04:30:27 +0000 (21:30 -0700)
Perlcritic does not want to see the trailing pipe in the two-args
form of open(), i.e.

open my $fh, "$cmd \Q$file\E |";

If $cmd were a single-token command name, it would make a lot more
sense to use four-or-more-args form "open FILEHANDLE,MODE,CMD,ARGS"
to avoid shell from expanding metacharacters in $file, but we do
expect multi-word string in $to_cmd and $cc_cmd to be expanded by
the shell, so we cannot rewrite it to

open my $fh, "-|", $cmd, $file;

for extra safety. At least, by using this in the three-arg form:

open my $fh, "-|", "$cmd \Q$file\E";

we can silence Perlcritic, even though we do not gain much safety by
doing so.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-send-email.perl
index fd8bfff3b29df199584503005e8405e699c7ab58..70cad15ec46d0ed32f3b97c792e9d975ece53fd8 100755 (executable)
@@ -1440,7 +1440,7 @@ sub recipients_cmd {
 
        my $sanitized_sender = sanitize_address($sender);
        my @addresses = ();
-       open my $fh, "$cmd \Q$file\E |"
+       open my $fh, "-|", "$cmd \Q$file\E"
            or die "($prefix) Could not execute '$cmd'";
        while (my $address = <$fh>) {
                $address =~ s/^\s*//g;