[PATCH] notmuch-mutt: use --format=text0 and xargs -0

classic Classic list List threaded Threaded
4 messages Options
Jani Nikula Jani Nikula
Reply | Threaded
Open this post in threaded view
|

[PATCH] notmuch-mutt: use --format=text0 and xargs -0

notmuch-mutt fails for message files with special characters such as
single quote in their filename. Use notmuch search --format=text0 and
xargs -0 combo to handle them.

Reported and tested by "dob1" on IRC.
---
 contrib/notmuch-mutt/notmuch-mutt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
index 0e46a8c1b95e..57f13075aa22 100755
--- a/contrib/notmuch-mutt/notmuch-mutt
+++ b/contrib/notmuch-mutt/notmuch-mutt
@@ -48,9 +48,9 @@ sub search($$$) {
     }
 
     empty_maildir($maildir);
-    system("notmuch search --output=files $dup_option $query"
+    system("notmuch search --format=text0 --output=files $dup_option $query"
    . " | sed -e 's: :\\\\ :g'"
-   . " | xargs -r -I searchoutput ln -s searchoutput $maildir/cur/");
+   . " | xargs -0 -r -I searchoutput ln -s searchoutput $maildir/cur/");
 }
 
 sub prompt($$) {
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Jani Nikula Jani Nikula
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] notmuch-mutt: use --format=text0 and xargs -0

On Tue, 27 Feb 2018, Jani Nikula <[hidden email]> wrote:

> notmuch-mutt fails for message files with special characters such as
> single quote in their filename. Use notmuch search --format=text0 and
> xargs -0 combo to handle them.
>
> Reported and tested by "dob1" on IRC.
> ---
>  contrib/notmuch-mutt/notmuch-mutt | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
> index 0e46a8c1b95e..57f13075aa22 100755
> --- a/contrib/notmuch-mutt/notmuch-mutt
> +++ b/contrib/notmuch-mutt/notmuch-mutt
> @@ -48,9 +48,9 @@ sub search($$$) {
>      }
>  
>      empty_maildir($maildir);
> -    system("notmuch search --output=files $dup_option $query"
> +    system("notmuch search --format=text0 --output=files $dup_option $query"
>     . " | sed -e 's: :\\\\ :g'"

Come to think of it, does this need sed -z too?

> -   . " | xargs -r -I searchoutput ln -s searchoutput $maildir/cur/");
> +   . " | xargs -0 -r -I searchoutput ln -s searchoutput $maildir/cur/");
>  }
>  
>  sub prompt($$) {
> --
> 2.11.0
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] notmuch-mutt: use --format=text0 and xargs -0

On Tue, Feb 27 2018, Jani Nikula wrote:

> On Tue, 27 Feb 2018, Jani Nikula <[hidden email]> wrote:
>> notmuch-mutt fails for message files with special characters such as
>> single quote in their filename. Use notmuch search --format=text0 and
>> xargs -0 combo to handle them.
>>
>> Reported and tested by "dob1" on IRC.
>> ---
>>  contrib/notmuch-mutt/notmuch-mutt | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
>> index 0e46a8c1b95e..57f13075aa22 100755
>> --- a/contrib/notmuch-mutt/notmuch-mutt
>> +++ b/contrib/notmuch-mutt/notmuch-mutt
>> @@ -48,9 +48,9 @@ sub search($$$) {
>>      }
>>  
>>      empty_maildir($maildir);
>> -    system("notmuch search --output=files $dup_option $query"
>> +    system("notmuch search --format=text0 --output=files $dup_option $query"
>>     . " | sed -e 's: :\\\\ :g'"
>
> Come to think of it, does this need sed -z too?

it looks  to me that sed can  be dropped.

btw how many non-coreutils xargs support -0 option ?




>
>> -   . " | xargs -r -I searchoutput ln -s searchoutput $maildir/cur/");
>> +   . " | xargs -0 -r -I searchoutput ln -s searchoutput $maildir/cur/");
>>  }
>>  
>>  sub prompt($$) {
>> --
>> 2.11.0
> _______________________________________________
> notmuch mailing list
> [hidden email]
> https://notmuchmail.org/mailman/listinfo/notmuch
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] notmuch-mutt: use --format=text0 and xargs -0

On Wed, Feb 28 2018, Tomi Ollila wrote:

> On Tue, Feb 27 2018, Jani Nikula wrote:
>
>> On Tue, 27 Feb 2018, Jani Nikula <[hidden email]> wrote:
>>> notmuch-mutt fails for message files with special characters such as
>>> single quote in their filename. Use notmuch search --format=text0 and
>>> xargs -0 combo to handle them.
>>>
>>> Reported and tested by "dob1" on IRC.
>>> ---
>>>  contrib/notmuch-mutt/notmuch-mutt | 4 ++--
>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
>>> index 0e46a8c1b95e..57f13075aa22 100755
>>> --- a/contrib/notmuch-mutt/notmuch-mutt
>>> +++ b/contrib/notmuch-mutt/notmuch-mutt
>>> @@ -48,9 +48,9 @@ sub search($$$) {
>>>      }
>>>  
>>>      empty_maildir($maildir);
>>> -    system("notmuch search --output=files $dup_option $query"
>>> +    system("notmuch search --format=text0 --output=files $dup_option $query"
>>>     . " | sed -e 's: :\\\\ :g'"
>>
>> Come to think of it, does this need sed -z too?
>
> it looks  to me that sed can  be dropped.
>
> btw how many non-coreutils xargs support -0 option ?

Checked (briefly):

openbsd, netbsd, macos and solaris xargs(1) (latest versions...) know -0 option.

so

    system("notmuch search --format=text0 --output=files $dup_option $query"
           . " | xargs -0 -r -I searchoutput ln -s searchoutput $maildir/cur/");

should be supported enough.


Tomi
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch