[PATCH] replace gnu xargs usage in notmuch-mutt with perl

Taylor Carpenter taylor at codecafe.com
Mon Apr 9 14:11:53 PDT 2012


---
 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



More information about the notmuch mailing list