[PATCH v2] completion: complete mimetype: search prefix

Tomi Ollila domo141 at gmail.com
Sun Oct 30 13:53:28 PDT 2016


Jani Nikula <jani at nikula.org> writes:

> On Tue, 25 Oct 2016, Tomi Ollila <domo141 at gmail.com> wrote:
>> Jani Nikula <jani at nikula.org> writes:
>>
>>> Use /etc/mime.types if available, with a homebrew sed parser, and fall
>>> back to a handful of common types otherwise.
>>
>> I'd suggest the following line:
>>
>> 	sed -n '/^[[:alpha:]]/ s/[[:space:]].*//p' /etc/mime.types
>>
>> I tested the sed expression works on Linux and Darwin (macOS sierra).
>
> $ sed --version
> sed (GNU sed) 4.2.2
>
> $ sed -n '/^[[:alpha:]]/ s/[[:space:]].*//p' /etc/mime.types | wc -l
> 411
>
> $ sed -n '/^[^ \t#]/{s/[ \t].*//;p;}' < /etc/mime.types | wc -l
> 787

Yes, I failed to notice that lines which did not have any space were
dropped from the output -- and Lucas Hoffmann's version handles that
case neatly (tried some alternatives, none so good (unless 's/\>.*//p')).

  sed -n '/^[[:alpha:]]/{s/[[:space:]].*//;p;}' /etc/mime.types


Now I get the same m5sums from the output of latest 2 in this message,
so now it is more properly tested (sorry about that :)

Tomi

>
> BR,
> Jani.


More information about the notmuch mailing list