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

Jani Nikula jani at nikula.org
Mon Aug 18 09:33:21 PDT 2014


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

---

This is probably unnecessary since

commit aff5af582ecbacb4004ad306c6ef463d61f1ed3a
Author: Jani Nikula <jani at 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



More information about the notmuch mailing list