Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / f5 / aeb6310e542b55a361d08b20069b878d84e26d
1 Return-Path: <tomi.ollila@iki.fi>\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 24051431FB6\r
6         for <notmuch@notmuchmail.org>; Tue, 10 Apr 2012 09:28:41 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\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 l+11-8K3D7R4 for <notmuch@notmuchmail.org>;\r
16         Tue, 10 Apr 2012 09:28:40 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66])\r
18         by olra.theworths.org (Postfix) with ESMTP id 21771431FAF\r
19         for <notmuch@notmuchmail.org>; Tue, 10 Apr 2012 09:28:40 -0700 (PDT)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id 7569668055; Tue, 10 Apr 2012 19:28:37 +0300 (EEST)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: Taylor Carpenter <taylor@codecafe.com>, notmuch@notmuchmail.org\r
24 Subject: Re: [PATCH] replace gnu xargs usage in notmuch-mutt with perl\r
25 In-Reply-To: <20120409211153.GA6497@codecafe.com>\r
26 References: <20120409211153.GA6497@codecafe.com>User-Agent:\r
27  Notmuch/0.12+77~gee11800       (http://notmuchmail.org) Emacs/23.3.1\r
28  (x86_64-unknown-linux-gnu)\r
29 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
30         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
31         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
32 Date: Tue, 10 Apr 2012 19:28:37 +0300\r
33 Message-ID: <m2hawr4klm.fsf@guru.guru-group.fi>\r
34 MIME-Version: 1.0\r
35 Content-Type: text/plain; charset=us-ascii\r
36 X-BeenThere: notmuch@notmuchmail.org\r
37 X-Mailman-Version: 2.1.13\r
38 Precedence: list\r
39 List-Id: "Use and development of the notmuch mail system."\r
40         <notmuch.notmuchmail.org>\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
44 List-Post: <mailto:notmuch@notmuchmail.org>\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
48 X-List-Received-Date: Tue, 10 Apr 2012 16:28:41 -0000\r
49 \r
50 On Tue, Apr 10 2012, Taylor Carpenter wrote:\r
51 \r
52 > ---\r
53 \r
54 what if instead of\r
55 \r
56 > +    my @filelist = `notmuch search --output=files $query`;\r
57 > +    foreach(@filelist) {\r
58 \r
59 there is:\r
60 \r
61   open my $fh, '-|', qw/notmuch search --output=files/, $query;\r
62   while (<$fh>) { \r
63    ...\r
64   }\r
65   unless (close $fh) {\r
66      # handle error case\r
67   }\r
68 \r
69 Tomi\r
70 \r
71 (in addition to more verbose commit message & unrelated change moved to\r
72 another commit)\r
73 \r
74 \r
75 >  contrib/notmuch-mutt/notmuch-mutt |   12 ++++++++----\r
76 >  1 files changed, 8 insertions(+), 4 deletions(-)\r
77 >\r
78 > diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt\r
79 > index 71206c3..dbe7f2d 100755\r
80 > --- a/contrib/notmuch-mutt/notmuch-mutt\r
81 > +++ b/contrib/notmuch-mutt/notmuch-mutt\r
82 > @@ -1,4 +1,4 @@\r
83 > -#!/usr/bin/perl -w\r
84 > +#!/usr/bin/env perl -w\r
85 >  #\r
86 >  # notmuch-mutt - notmuch (of a) helper for Mutt\r
87 >  #\r
88 > @@ -12,6 +12,7 @@ use strict;\r
89 >  use warnings;\r
90 >  \r
91 >  use File::Path;\r
92 > +use File::Basename;\r
93 >  use Getopt::Long qw(:config no_getopt_compat);\r
94 >  use Mail::Internet;\r
95 >  use Mail::Box::Maildir;\r
96 > @@ -41,9 +42,12 @@ sub search($$) {\r
97 >      $query = shell_quote($query);\r
98 >  \r
99 >      empty_maildir($maildir);\r
100 > -    system("notmuch search --output=files $query"\r
101 > -        . " | sed -e 's: :\\\\ :g'"\r
102 > -        . " | xargs --no-run-if-empty ln -s -t $maildir/cur/");\r
103 > +    my @filelist = `notmuch search --output=files $query`;\r
104 > +    foreach(@filelist) {\r
105 > +        chomp;\r
106 > +        my $target = sprintf("$maildir/cur/%s", basename($_));\r
107 > +        symlink($_, $target);\r
108 > +    }\r
109 >  }\r
110 >  \r
111 >  sub prompt($$) {\r
112 > -- \r
113 > 1.7.7.4\r
114 >\r
115 > _______________________________________________\r
116 > notmuch mailing list\r
117 > notmuch@notmuchmail.org\r
118 > http://notmuchmail.org/mailman/listinfo/notmuch\r