Re: [PATCH] completion: fail silently if _init_completion is not found

Subject: Re: [PATCH] completion: fail silently if _init_completion is not found

Date: Mon, 18 Aug 2014 20:24:33 +0300

To: Jani Nikula, notmuch@notmuchmail.org

Cc:

From: Tomi Ollila


On Mon, Aug 18 2014, Jani Nikula <jani@nikula.org> wrote:

> The completion script depends on bash-completion 1.90 or later, with
> _init_completion function. If that's not present, for some reason, the
> completion currently fails with an ugly message, messing up user's
> command line:
>
> $ notmuch -bash: _init_completion: command not found
>
> It's better to just not complete
>
> ---

LGTM.

Tomi


>
> This is probably unnecessary since
>
> commit aff5af582ecbacb4004ad306c6ef463d61f1ed3a
> Author: Jani Nikula <jani@nikula.org>
> Date:   Sun Feb 2 18:47:57 2014 +0200
>
>     configure: only install bash completion if supported
>
> but should not do harm.
> ---
>  completion/notmuch-completion.bash | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash
> index d88c5e7d965e..0571dc9da8e3 100644
> --- a/completion/notmuch-completion.bash
> +++ b/completion/notmuch-completion.bash
> @@ -395,6 +395,10 @@ _notmuch()
>  {
>      local _notmuch_commands="compact config count dump help insert new reply restore search setup show tag"
>      local arg cur prev words cword split
> +
> +    # require bash-completion with _init_completion
> +    type -t _init_completion >/dev/null 2>&1 || return
> +
>      _init_completion || return
>  
>      COMPREPLY=()
> -- 
> 2.0.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

Thread: