From 10e18c69568a37c273b1f1cb140188928793a10b Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Thu, 12 Apr 2012 10:07:54 +0300 Subject: [PATCH] Re: [PATCH] notmuch-mutt: replace gnu sed and xargs with perl --- 9c/30711acf86cff669270170f010b587219a71ea | 113 ++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 9c/30711acf86cff669270170f010b587219a71ea diff --git a/9c/30711acf86cff669270170f010b587219a71ea b/9c/30711acf86cff669270170f010b587219a71ea new file mode 100644 index 000000000..3bf85bfeb --- /dev/null +++ b/9c/30711acf86cff669270170f010b587219a71ea @@ -0,0 +1,113 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id C7EFC431FAF + for ; Thu, 12 Apr 2012 00:07:57 -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 bIriozQ2d-Ng for ; + Thu, 12 Apr 2012 00:07:57 -0700 (PDT) +Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66]) + by olra.theworths.org (Postfix) with ESMTP id 2D708431FAE + for ; Thu, 12 Apr 2012 00:07:57 -0700 (PDT) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id 6C47468055; Thu, 12 Apr 2012 10:07:54 +0300 (EEST) +From: Tomi Ollila +To: Taylor Carpenter , notmuch@notmuchmail.org +Subject: Re: [PATCH] notmuch-mutt: replace gnu sed and xargs with perl +In-Reply-To: <20120412002953.GA27056@codecafe.com> +References: <20120412002953.GA27056@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: Thu, 12 Apr 2012 07:07:57 -0000 + +On Thu, Apr 12 2012, Taylor Carpenter wrote: + +> External software dependencies removed: sed and xargs. +> +> Sed shell escaping is handled automatically with perl symlink function. +> +> The xargs usage is specific to gnu xargs (fails on bsd xargs, etc). +> +> NOTE: The current query pulls the list of files into an array all at +> once. The larger the list the more memory used. +> --- + +-1 + +It is not too hard to read the filelist from pipe; Check the example +I sent in id:"m2hawr4klm.fsf@guru.guru-group.fi" + + +Btw: what if there are same filenames in different directories that +match. With basename there will be collision. Alternatives: + +* instead of basename convert '/':s to '_':s +* take md5 or sha1 sum of the filename +* take md5 or sha1 sum of dirname of the filename and concatenate... + +Tomi + +> contrib/notmuch-mutt/notmuch-mutt | 9 ++++++--- +> 1 files changed, 6 insertions(+), 3 deletions(-) +> +> diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt +> index 424f9a3..c995022 100755 +> --- a/contrib/notmuch-mutt/notmuch-mutt +> +++ b/contrib/notmuch-mutt/notmuch-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,11 @@ 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; +> + symlink($_, "$maildir/cur/" . basename($_)); +> + } +> } +> +> sub prompt($$) { +> -- +> 1.7.7.4 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2