unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Make notmuch-mutt script more portable
@ 2020-03-16 18:27 Greg Anders
  2020-03-16 22:04 ` Tomi Ollila
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Anders @ 2020-03-16 18:27 UTC (permalink / raw)
  To: notmuch

The -D flag to install (used in the Makefile) is GNU-specific and does
not work on BSD distributions (i.e. macOS). Likewise with the xargs -r
flag. These changes use portable alternatives to these flags while
preserving the exact behavior.
---
 contrib/notmuch-mutt/Makefile     | 6 +++---
 contrib/notmuch-mutt/notmuch-mutt | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/notmuch-mutt/Makefile b/contrib/notmuch-mutt/Makefile
index 855438be..de933eaa 100644
--- a/contrib/notmuch-mutt/Makefile
+++ b/contrib/notmuch-mutt/Makefile
@@ -15,11 +15,11 @@ README.html: README
 	markdown $< > $@
 
 install: all
-	mkdir -p $(DESTDIR)$(prefix)/bin
+	mkdir -p $(DESTDIR)$(prefix)/bin $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(sysconfdir)/Muttrc.d
 	sed "1s|^#!.*|#! $(PERL_ABSOLUTE)|" < $(NAME) > $(DESTDIR)$(prefix)/bin/$(NAME)
 	chmod 755 $(DESTDIR)$(prefix)/bin/$(NAME)
-	install -D -m 644 $(NAME).1 $(DESTDIR)$(mandir)/man1/$(NAME).1
-	install -D -m 644 $(NAME).rc $(DESTDIR)$(sysconfdir)/Muttrc.d/$(NAME).rc
+	install -m 644 $(NAME).1 $(DESTDIR)$(mandir)/man1/
+	install -m 644 $(NAME).rc $(DESTDIR)$(sysconfdir)/Muttrc.d/
 
 clean:
 	rm -f notmuch-mutt.1 README.html
diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
index 0e46a8c1..d33223bd 100755
--- a/contrib/notmuch-mutt/notmuch-mutt
+++ b/contrib/notmuch-mutt/notmuch-mutt
@@ -50,7 +50,7 @@ sub search($$$) {
     empty_maildir($maildir);
     system("notmuch search --output=files $dup_option $query"
 	   . " | sed -e 's: :\\\\ :g'"
-	   . " | xargs -r -I searchoutput ln -s searchoutput $maildir/cur/");
+	   . " | while IFS= read -r searchoutput; do ln -s \$searchoutput $maildir/cur/; done");
 }
 
 sub prompt($$) {
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Make notmuch-mutt script more portable
  2020-03-16 18:27 [PATCH] Make notmuch-mutt script more portable Greg Anders
@ 2020-03-16 22:04 ` Tomi Ollila
  2020-03-23  1:58   ` David Bremner
  0 siblings, 1 reply; 3+ messages in thread
From: Tomi Ollila @ 2020-03-16 22:04 UTC (permalink / raw)
  To: notmuch

On Mon, Mar 16 2020, Greg Anders wrote:

> The -D flag to install (used in the Makefile) is GNU-specific and does
> not work on BSD distributions (i.e. macOS). Likewise with the xargs -r
> flag. These changes use portable alternatives to these flags while
> preserving the exact behavior.

Looks more portable to me. +1. 

The system and shell pipeline in the search() function has always irritated
me when I've looked it (a bit). At the end of this email is model of
potential replacement code which I just cooked up, which SomeOne(TM)
may implement =D

> ---
>  contrib/notmuch-mutt/Makefile     | 6 +++---
>  contrib/notmuch-mutt/notmuch-mutt | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/contrib/notmuch-mutt/Makefile b/contrib/notmuch-mutt/Makefile
> index 855438be..de933eaa 100644
> --- a/contrib/notmuch-mutt/Makefile
> +++ b/contrib/notmuch-mutt/Makefile
> @@ -15,11 +15,11 @@ README.html: README
>  	markdown $< > $@
>  
>  install: all
> -	mkdir -p $(DESTDIR)$(prefix)/bin
> +	mkdir -p $(DESTDIR)$(prefix)/bin $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(sysconfdir)/Muttrc.d
>  	sed "1s|^#!.*|#! $(PERL_ABSOLUTE)|" < $(NAME) > $(DESTDIR)$(prefix)/bin/$(NAME)
>  	chmod 755 $(DESTDIR)$(prefix)/bin/$(NAME)
> -	install -D -m 644 $(NAME).1 $(DESTDIR)$(mandir)/man1/$(NAME).1
> -	install -D -m 644 $(NAME).rc $(DESTDIR)$(sysconfdir)/Muttrc.d/$(NAME).rc
> +	install -m 644 $(NAME).1 $(DESTDIR)$(mandir)/man1/
> +	install -m 644 $(NAME).rc $(DESTDIR)$(sysconfdir)/Muttrc.d/
>  
>  clean:
>  	rm -f notmuch-mutt.1 README.html
> diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
> index 0e46a8c1..d33223bd 100755
> --- a/contrib/notmuch-mutt/notmuch-mutt
> +++ b/contrib/notmuch-mutt/notmuch-mutt
> @@ -50,7 +50,7 @@ sub search($$$) {
>      empty_maildir($maildir);
>      system("notmuch search --output=files $dup_option $query"
>  	   . " | sed -e 's: :\\\\ :g'"
> -	   . " | xargs -r -I searchoutput ln -s searchoutput $maildir/cur/");
> +	   . " | while IFS= read -r searchoutput; do ln -s \$searchoutput $maildir/cur/; done");
>  }
>  
>  sub prompt($$) {
> -- 
> 2.25.1

--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--

safe to run; "write" code outcommented, example print added.

--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--

#!/usr/bin/perl
# -*- mode: cperl; cperl-indent-level: 4 -*-
# $ test-search-code.pl $

use 5.8.1;
use strict;
use warnings;

#$ENV{'PATH'} = '/sbin:/usr/sbin:/bin:/usr/bin';

sub search($$$) {
    my ($maildir, $remove_dups, $query) = @_;

    my @opts;
    push @opts, '--duplicate=1' if $remove_dups;
    push @opts, $query;

    #empty_maildir($maildir);
    open P, '-|', qw/notmuch search --output=files/, @opts or die $!;
    while (<P>) {
	chomp;
	my $f = $_;
	s|.*/||;
	print qq'$f "$maildir/$_" or die \$!;\n';
	#symlink $f "$maildir/$_" or die $!;
    }
    close P;
}

search 'maildir', 0, 'date:1d..';

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Make notmuch-mutt script more portable
  2020-03-16 22:04 ` Tomi Ollila
@ 2020-03-23  1:58   ` David Bremner
  0 siblings, 0 replies; 3+ messages in thread
From: David Bremner @ 2020-03-23  1:58 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

Tomi Ollila <tomi.ollila@iki.fi> writes:

> On Mon, Mar 16 2020, Greg Anders wrote:
>
>> The -D flag to install (used in the Makefile) is GNU-specific and does
>> not work on BSD distributions (i.e. macOS). Likewise with the xargs -r
>> flag. These changes use portable alternatives to these flags while
>> preserving the exact behavior.
>
> Looks more portable to me. +1. 
>

pushed,

d

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-23  1:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-16 18:27 [PATCH] Make notmuch-mutt script more portable Greg Anders
2020-03-16 22:04 ` Tomi Ollila
2020-03-23  1:58   ` David Bremner

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