X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=contrib%2Fnotmuch-mutt%2Fnotmuch-mutt;h=1e12038cdbda50bb29f6e98d49fc2b891b5cfe49;hb=d155f29eca0ab9afc35292e447fb67b1c73e9df9;hp=97fb2d85160cb9a495de68c31103671beeae3fc0;hpb=e3e03fb718de9790bc9b7a78210f42559bff24e5;p=notmuch diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt index 97fb2d85..1e12038c 100755 --- a/contrib/notmuch-mutt/notmuch-mutt +++ b/contrib/notmuch-mutt/notmuch-mutt @@ -2,7 +2,7 @@ # # notmuch-mutt - notmuch (of a) helper for Mutt # -# Copyright: © 2011-2015 Stefano Zacchiroli +# Copyright: © 2011-2015 Stefano Zacchiroli # License: GNU General Public License (GPL), version 3 or above # # See the bottom of this file for more documentation. @@ -12,6 +12,7 @@ use strict; use warnings; use File::Path; +use File::Basename; use Getopt::Long qw(:config no_getopt_compat); use Mail::Header; use Mail::Box::Maildir; @@ -41,16 +42,17 @@ sub search($$$) { my ($maildir, $remove_dups, $query) = @_; my $dup_option = ""; - $query = shell_quote($query); - - if ($remove_dups) { - $dup_option = "--duplicate=1"; - } + my @args = qw/notmuch search --output=files/; + push @args, "--duplicate=1" if $remove_dups; + push @args, $query; empty_maildir($maildir); - system("notmuch search --output=files $dup_option $query" - . " | sed -e 's: :\\\\ :g'" - . " | xargs -r -I searchoutput ln -s searchoutput $maildir/cur/"); + open my $pipe, '-|', @args or die "Running @args failed: $!\n"; + while (<$pipe>) { + chomp; + my $ln = "$maildir/cur/" . basename $_; + symlink $_, "$ln" or warn "Failed to symlink '$_', '$ln': $!\n"; + } } sub prompt($$) { @@ -91,7 +93,7 @@ sub get_message_id() { $mid = $1; } else { # Message-ID header not found, synthesize a message id # based on SHA1, as notmuch would do. See: - # http://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c + # https://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c my $sha = Digest::SHA->new(1); $sha->add($_) foreach(@headers); $sha->addfile(\*STDIN);