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 1F666431FAF for ; Wed, 11 Apr 2012 17:29:58 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 g67iQUM2Xv6G for ; Wed, 11 Apr 2012 17:29:56 -0700 (PDT) Received: from mail-ob0-f181.google.com (mail-ob0-f181.google.com [209.85.214.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 803DE431FAE for ; Wed, 11 Apr 2012 17:29:56 -0700 (PDT) Received: by obbwd20 with SMTP id wd20so2187452obb.26 for ; Wed, 11 Apr 2012 17:29:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent:x-gm-message-state; bh=dUU69oB4BOWR6CEKJ5ItjAJygKSVJo3v7m/Ja6ISXSg=; b=UvWXqlSm5rgB1uMyRlhZExK/1wgc+eSKsQCDxKku/Aq4CYGx+/9oVgAwN4VJGFVrqz d/3Mox1PC9MzVkiwk8tQZJCP51QJzesZ99rt4hzP0AsfKX6ZLYBOjxIT/M5/fqtlOfnZ 4swY5msK4amX4VowtZAbJ4juHXe/wbuQkAuf+RqWz9r1H3lCp06EbxSAg/68zcAM6Fav 0+OS2OjbLsRZU7KaHR/egpipdbVM0FrTu8RHtPafQPPqxYbeuGChe69CmQAQytIlXexf l7R66XMdEXiT6KJjpFO4bgQfb8oEC+aYUQ9nSm8EkDAGJJEQootnrfP1E3XqL7ME6yaF ZWzA== Received: by 10.182.122.36 with SMTP id lp4mr455656obb.64.1334190595936; Wed, 11 Apr 2012 17:29:55 -0700 (PDT) Received: from localhost (cpe-173-174-57-204.austin.res.rr.com. [173.174.57.204]) by mx.google.com with ESMTPS id yw3sm4676970obb.7.2012.04.11.17.29.54 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Apr 2012 17:29:55 -0700 (PDT) Date: Wed, 11 Apr 2012 19:29:53 -0500 From: Taylor Carpenter To: notmuch@notmuchmail.org Subject: [PATCH] notmuch-mutt: replace gnu sed and xargs with perl Message-ID: <20120412002953.GA27056@codecafe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQl4ZQ5paBJUzlpikzBVgYeIZyzynqG6mvzWhCelq4VMXO3L2uEKbvAAfevjVNAwM5dbjsGN 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 00:29:58 -0000 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. --- 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