* Re: [PATCH] replace gnu xargs usage in notmuch-mutt with perl
@ 2012-04-10 8:25 Stefano Zacchiroli
0 siblings, 0 replies; 4+ messages in thread
From: Stefano Zacchiroli @ 2012-04-10 8:25 UTC (permalink / raw)
To: Taylor Carpenter; +Cc: notmuch
Hi Taylor, thanks for your patch. It makes sense to me, and has the
beneficial side effect of avoiding a sed pass to do some poor men shell
escaping.
Before applying, however, can you please update it to:
- include a reasonable comment (as suggested by David)
- avoid patching the shebang line (ditto)
- coalesce the sprintf() line into the following symlink line (using
sprintf seems redundant here: it's plain string concatenation)
Thanks!
Cheers.
PS please Cc:-me on replies
--
Stefano Zacchiroli zack@{upsilon.cc,pps.jussieu.fr,debian.org} . o .
Maître de conférences ...... http://upsilon.cc/zack ...... . . o
Debian Project Leader ....... @zack on identi.ca ....... o o o
« the first rule of tautology club is the first rule of tautology club »
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] replace gnu xargs usage in notmuch-mutt with perl
@ 2012-04-09 21:11 Taylor Carpenter
2012-04-09 22:17 ` David Bremner
2012-04-10 16:28 ` Tomi Ollila
0 siblings, 2 replies; 4+ messages in thread
From: Taylor Carpenter @ 2012-04-09 21:11 UTC (permalink / raw)
To: notmuch
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] replace gnu xargs usage in notmuch-mutt with perl
2012-04-09 21:11 Taylor Carpenter
@ 2012-04-09 22:17 ` David Bremner
2012-04-10 16:28 ` Tomi Ollila
1 sibling, 0 replies; 4+ messages in thread
From: David Bremner @ 2012-04-09 22:17 UTC (permalink / raw)
To: Taylor Carpenter, notmuch
Hi Taylor, and thanks for the patch.
In general for notmuch patches we prefer
- some kind of commit message beyond the one line summary explaining the
rationale for the change.
- not to have unrelated changes (/usr/bin/env perl) in the patch.
d
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] replace gnu xargs usage in notmuch-mutt with perl
2012-04-09 21:11 Taylor Carpenter
2012-04-09 22:17 ` David Bremner
@ 2012-04-10 16:28 ` Tomi Ollila
1 sibling, 0 replies; 4+ messages in thread
From: Tomi Ollila @ 2012-04-10 16:28 UTC (permalink / raw)
To: Taylor Carpenter, notmuch
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-10 16:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-10 8:25 [PATCH] replace gnu xargs usage in notmuch-mutt with perl Stefano Zacchiroli
-- strict thread matches above, loose matches on Subject: below --
2012-04-09 21:11 Taylor Carpenter
2012-04-09 22:17 ` David Bremner
2012-04-10 16:28 ` Tomi Ollila
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).