From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 24051431FB6 for ; Tue, 10 Apr 2012 09:28:41 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l+11-8K3D7R4 for ; Tue, 10 Apr 2012 09:28:40 -0700 (PDT) Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66]) by olra.theworths.org (Postfix) with ESMTP id 21771431FAF for ; Tue, 10 Apr 2012 09:28:40 -0700 (PDT) Received: by guru.guru-group.fi (Postfix, from userid 501) id 7569668055; Tue, 10 Apr 2012 19:28:37 +0300 (EEST) From: Tomi Ollila To: Taylor Carpenter , notmuch@notmuchmail.org Subject: Re: [PATCH] replace gnu xargs usage in notmuch-mutt with perl In-Reply-To: <20120409211153.GA6497@codecafe.com> References: <20120409211153.GA6497@codecafe.com>User-Agent: Notmuch/0.12+77~gee11800 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Apr 2012 16:28:41 -0000 On Tue, Apr 10 2012, Taylor Carpenter wrote: > --- what if instead of > + my @filelist = `notmuch search --output=files $query`; > + foreach(@filelist) { there is: open my $fh, '-|', qw/notmuch search --output=files/, $query; while (<$fh>) { ... } unless (close $fh) { # handle error case } Tomi (in addition to more verbose commit message & unrelated change moved to another commit) > contrib/notmuch-mutt/notmuch-mutt | 12 ++++++++---- > 1 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt > index 71206c3..dbe7f2d 100755 > --- a/contrib/notmuch-mutt/notmuch-mutt > +++ b/contrib/notmuch-mutt/notmuch-mutt > @@ -1,4 +1,4 @@ > -#!/usr/bin/perl -w > +#!/usr/bin/env perl -w > # > # notmuch-mutt - notmuch (of a) helper for Mutt > # > @@ -12,6 +12,7 @@ use strict; > use warnings; > > use File::Path; > +use File::Basename; > use Getopt::Long qw(:config no_getopt_compat); > use Mail::Internet; > use Mail::Box::Maildir; > @@ -41,9 +42,12 @@ sub search($$) { > $query = shell_quote($query); > > empty_maildir($maildir); > - system("notmuch search --output=files $query" > - . " | sed -e 's: :\\\\ :g'" > - . " | xargs --no-run-if-empty ln -s -t $maildir/cur/"); > + my @filelist = `notmuch search --output=files $query`; > + foreach(@filelist) { > + chomp; > + my $target = sprintf("$maildir/cur/%s", basename($_)); > + symlink($_, $target); > + } > } > > sub prompt($$) { > -- > 1.7.7.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch