1 Return-Path: <zack@upsilon.cc>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 02AE3431FBC
\r
6 for <notmuch@notmuchmail.org>; Thu, 14 Feb 2013 00:37:19 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 0Gkb2LB44SyG for <notmuch@notmuchmail.org>;
\r
16 Thu, 14 Feb 2013 00:37:16 -0800 (PST)
\r
17 Received: from upsilon.hackadomia.org (upsilon.hackadomia.org
\r
18 [91.121.245.170]) by olra.theworths.org (Postfix) with ESMTP id B04CD431FAF
\r
19 for <notmuch@notmuchmail.org>; Thu, 14 Feb 2013 00:37:15 -0800 (PST)
\r
20 Received: from usha.takhisis.invalid (unknown
\r
21 [IPv6:2a01:e34:eecc:42f0:76e5:bff:fea7:56b8])
\r
22 by upsilon.hackadomia.org (Postfix) with ESMTPSA id 954487E00D;
\r
23 Thu, 14 Feb 2013 09:37:13 +0100 (CET)
\r
24 Received: by usha.takhisis.invalid (Postfix, from userid 1000)
\r
25 id 0ED45680849; Thu, 14 Feb 2013 09:37:13 +0100 (CET)
\r
26 Date: Thu, 14 Feb 2013 09:37:13 +0100
\r
27 From: Stefano Zacchiroli <zack@upsilon.cc>
\r
28 To: Profpatsch <mail@profpatsch.de>
\r
29 Subject: Re: notmuch-mutt: Use of uninitialized value.
\r
30 Message-ID: <20130214083713.GA4123@upsilon.cc>
\r
31 References: <20130212005801.GA8419@soarin> <20130213223535.GA3258@zaogao.lan>
\r
32 <20130213233657.GA4489@soarin>
\r
34 Content-Type: multipart/mixed; boundary="YZ5djTAD1cGYuMQK"
\r
35 Content-Disposition: inline
\r
36 Content-Transfer-Encoding: 8bit
\r
37 In-Reply-To: <20130213233657.GA4489@soarin>
\r
38 User-Agent: Mutt/1.5.21 (2010-09-15)
\r
39 Cc: David Bremner <bremner@unb.ca>, notmuch@notmuchmail.org
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.13
\r
43 List-Id: "Use and development of the notmuch mail system."
\r
44 <notmuch.notmuchmail.org>
\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
48 List-Post: <mailto:notmuch@notmuchmail.org>
\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
52 X-List-Received-Date: Thu, 14 Feb 2013 08:37:19 -0000
\r
56 Content-Type: text/plain; charset=utf-8
\r
57 Content-Disposition: inline
\r
58 Content-Transfer-Encoding: 8bit
\r
60 On Thu, Feb 14, 2013 at 12:36:58AM +0100, Profpatsch wrote:
\r
61 > On 13-02-13 02:35pm, Kevin J. McCarthy wrote:
\r
62 > > A more likely idea is to check whether you have $pipe_decode set.
\r
65 > So much for copying a basic rc from someone else.
\r
66 > Of course, that was it and I’m officially an idiot.
\r
68 Neat, thanks Kevin for debugging the issue down to $pipe_decode (which
\r
69 I've never used, mutt never stops to amaze me :-)).
\r
71 > And apparently Mail::Internet errors out if there is no Message-ID.
\r
72 > (Which mentioned in the docs at CPAN…)
\r
76 Right, but still a more graceful failure model would be nice.
\r
78 Please find attached a patch that in such cases should 1) give a
\r
79 supposedly nice error message explaining what's going on and 2) empty
\r
80 the results dir to avoid showing you unrelated results. It works for me.
\r
81 But extra checking never hurts, in particular for the tag action, which
\r
82 I don't personally use.
\r
84 I guess it would also be nice to actually disable $pipe_decode in the
\r
85 relevant Mutt macros, but I'm not sure about to do that without
\r
86 interfering with user desired configuration. Kevin: do you know if there
\r
87 is a common Mutt trick to store the value of a variable before changing
\r
88 it, and restoring it a posteriori? More isolation for this kind of
\r
89 things in Mutt would definitely be welcome...
\r
93 Stefano Zacchiroli . . . . . . . zack@upsilon.cc . . . . o . . . o . o
\r
94 Maître de conférences . . . . . http://upsilon.cc/zack . . . o . . . o o
\r
95 Debian Project Leader . . . . . . @zack on identi.ca . . o o o . . . o .
\r
96 « the first rule of tautology club is the first rule of tautology club »
\r
99 Content-Type: text/x-diff; charset=us-ascii
\r
100 Content-Disposition: attachment;
\r
101 filename="0001-notmuch-mutt-more-graceful-handling-of-missing-Messa.patch"
\r
103 >From b67ab95855ce7d279d8c0b3ddcbc20e679afc70b Mon Sep 17 00:00:00 2001
\r
104 From: Stefano Zacchiroli <zack@upsilon.cc>
\r
105 Date: Thu, 14 Feb 2013 09:31:37 +0100
\r
106 Subject: [PATCH] notmuch-mutt: more graceful handling of missing Message-Id
\r
110 - the "thread" action would print an error and empty results dir
\r
111 - the "tag action would print an error
\r
113 contrib/notmuch-mutt/notmuch-mutt | 8 +++++++-
\r
114 1 file changed, 7 insertions(+), 1 deletion(-)
\r
116 diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
\r
117 index d14709d..bc97908 100755
\r
118 --- a/contrib/notmuch-mutt/notmuch-mutt
\r
119 +++ b/contrib/notmuch-mutt/notmuch-mutt
\r
120 @@ -121,7 +121,8 @@ sub prompt($$) {
\r
122 sub get_message_id() {
\r
123 my $mail = Mail::Internet->new(\*STDIN);
\r
124 - $mail->head->get("message-id") =~ /^<(.*)>$/; # get message-id
\r
125 + my $mid = $mail->head->get("message-id") or return undef;
\r
126 + $mid =~ /^<(.*)>$/; # get message-id value
\r
130 @@ -142,6 +143,10 @@ sub thread_action($$@) {
\r
131 my ($results_dir, $remove_dups, @params) = @_;
\r
133 my $mid = get_message_id();
\r
134 + if (! defined $mid) {
\r
135 + empty_maildir($results_dir);
\r
136 + die "notmuch-mutt: cannot find Message-Id, abort.\n";
\r
138 my $search_cmd = 'notmuch search --output=threads ' . shell_quote("id:$mid");
\r
139 my $tid = `$search_cmd`; # get thread id
\r
141 @@ -151,6 +156,7 @@ sub thread_action($$@) {
\r
143 sub tag_action(@) {
\r
144 my $mid = get_message_id();
\r
145 + defined $mid or die "notmuch-mutt: cannot find Message-Id, abort.\n";
\r
147 system("notmuch tag "
\r
148 . shell_quote(join(' ', @_))
\r
153 --YZ5djTAD1cGYuMQK--
\r