X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=contrib%2Fnotmuch-mutt%2Fnotmuch-mutt;fp=contrib%2Fnotmuch-mutt%2Fnotmuch-mutt;h=bc97908e00600ba40538b43fd6fbbe707c2958fa;hp=d14709df6eb3bccdd054a18f0ffa1cc984167d00;hb=9b98e9bcbfe546a6e919408e1ada6d85316e6a94;hpb=9bd4ddc0c582d721343916139e0517342e8beaab diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt index d14709df..bc97908e 100755 --- a/contrib/notmuch-mutt/notmuch-mutt +++ b/contrib/notmuch-mutt/notmuch-mutt @@ -121,7 +121,8 @@ sub prompt($$) { sub get_message_id() { my $mail = Mail::Internet->new(\*STDIN); - $mail->head->get("message-id") =~ /^<(.*)>$/; # get message-id + my $mid = $mail->head->get("message-id") or return undef; + $mid =~ /^<(.*)>$/; # get message-id value return $1; } @@ -142,6 +143,10 @@ sub thread_action($$@) { my ($results_dir, $remove_dups, @params) = @_; my $mid = get_message_id(); + if (! defined $mid) { + empty_maildir($results_dir); + die "notmuch-mutt: cannot find Message-Id, abort.\n"; + } my $search_cmd = 'notmuch search --output=threads ' . shell_quote("id:$mid"); my $tid = `$search_cmd`; # get thread id chomp($tid); @@ -151,6 +156,7 @@ sub thread_action($$@) { sub tag_action(@) { my $mid = get_message_id(); + defined $mid or die "notmuch-mutt: cannot find Message-Id, abort.\n"; system("notmuch tag " . shell_quote(join(' ', @_))