From: Stefano Zacchiroli Date: Thu, 14 Feb 2013 08:37:13 +0000 (+0100) Subject: notmuch-mutt: Use of uninitialized value. X-Git-Tag: 0.16_rc1~211 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=9b98e9bcbfe546a6e919408e1ada6d85316e6a94 notmuch-mutt: Use of uninitialized value. On Thu, Feb 14, 2013 at 12:36:58AM +0100, Profpatsch wrote: > On 13-02-13 02:35pm, Kevin J. McCarthy wrote: > > A more likely idea is to check whether you have $pipe_decode set. > > BRILLIANT! > So much for copying a basic rc from someone else. > Of course, that was it and I’m officially an idiot. Neat, thanks Kevin for debugging the issue down to $pipe_decode (which I've never used, mutt never stops to amaze me :-)). > And apparently Mail::Internet errors out if there is no Message-ID. > (Which mentioned in the docs at CPAN…) > > Mystery solved. Right, but still a more graceful failure model would be nice. Please find attached a patch that in such cases should 1) give a supposedly nice error message explaining what's going on and 2) empty the results dir to avoid showing you unrelated results. It works for me. But extra checking never hurts, in particular for the tag action, which I don't personally use. I guess it would also be nice to actually disable $pipe_decode in the relevant Mutt macros, but I'm not sure about to do that without interfering with user desired configuration. Kevin: do you know if there is a common Mutt trick to store the value of a variable before changing it, and restoring it a posteriori? More isolation for this kind of things in Mutt would definitely be welcome... Cheers. -- Stefano Zacchiroli . . . . . . . zack@upsilon.cc . . . . o . . . o . o Maître de conférences . . . . . http://upsilon.cc/zack . . . o . . . o o Debian Project Leader . . . . . . @zack on identi.ca . . o o o . . . o . « the first rule of tautology club is the first rule of tautology club » From b67ab95855ce7d279d8c0b3ddcbc20e679afc70b Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 14 Feb 2013 09:31:37 +0100 Subject: [PATCH] notmuch-mutt: more graceful handling of missing Message-Id errors in particular: - the "thread" action would print an error and empty results dir - the "tag action would print an error --- 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(' ', @_))