From: Tomi Ollila <tomi.ollila@iki.fi>
To: Taylor Carpenter <taylor@codecafe.com>, notmuch@notmuchmail.org
Subject: Re: [PATCH] replace gnu xargs usage in notmuch-mutt with perl
Date: Tue, 10 Apr 2012 19:28:37 +0300 [thread overview]
Message-ID: <m2hawr4klm.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <20120409211153.GA6497@codecafe.com>
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
next prev parent reply other threads:[~2012-04-10 16:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-09 21:11 [PATCH] replace gnu xargs usage in notmuch-mutt with perl Taylor Carpenter
2012-04-09 22:17 ` David Bremner
2012-04-10 16:28 ` Tomi Ollila [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-04-10 8:25 Stefano Zacchiroli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2hawr4klm.fsf@guru.guru-group.fi \
--to=tomi.ollila@iki.fi \
--cc=notmuch@notmuchmail.org \
--cc=taylor@codecafe.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).