[PATCH] completion: fail silently if _init_completion is not found
authorJani Nikula <jani@nikula.org>
Mon, 18 Aug 2014 16:33:21 +0000 (19:33 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:04:13 +0000 (10:04 -0800)
30/a57a9de8c3348f57cae8d2ee5781283309171a [new file with mode: 0644]

diff --git a/30/a57a9de8c3348f57cae8d2ee5781283309171a b/30/a57a9de8c3348f57cae8d2ee5781283309171a
new file mode 100644 (file)
index 0000000..dc4cbc8
--- /dev/null
@@ -0,0 +1,104 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 1AB22431FAE\r
+       for <notmuch@notmuchmail.org>; Mon, 18 Aug 2014 09:33:42 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id YYC2Oh4cBkat for <notmuch@notmuchmail.org>;\r
+       Mon, 18 Aug 2014 09:33:34 -0700 (PDT)\r
+Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com\r
+       [209.85.212.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 01BC7431FBC\r
+       for <notmuch@notmuchmail.org>; Mon, 18 Aug 2014 09:33:28 -0700 (PDT)\r
+Received: by mail-wi0-f171.google.com with SMTP id hi2so4022748wib.10\r
+       for <notmuch@notmuchmail.org>; Mon, 18 Aug 2014 09:33:26 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=1e100.net; s=20130820;\r
+       h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
+       bh=byi9LzKAig0HNDZfVDvvdvNxJNTbrzEPmDu+sJwRKJ4=;\r
+       b=RJG0t0426M3jMz/FR/Vhp6ik/+OrY3NXGOp5W/1zrLGoCqFYc8d3MY/1D+hUko3pG8\r
+       Vc6CZqzKd2pqj3Bc15lCjidvUdHDEpZpHfIb9mShtn3iYe4DKYJJr5Rcu3GDEc25LkAh\r
+       ae0aPZhKoHknyyKVGHBJrZMvkkU4trsR7bea9EcQil7+gC5IzThRxw8+2enTjmPbrGFk\r
+       vmmTBBcvtrrvJYKLUZV8blC/3QLWIxZJLR9G6i1L6/kGozcM8lb+IcR86Cq/Ey+p3Ha2\r
+       Z6Uf7QdnAYBVrQCKN10DdgvKnJjL+V2J/obCfDzKpJKZcGNrhA0nFjiF2K+kkZtiCGfh\r
+       tQog==\r
+X-Gm-Message-State:\r
+ ALoCoQldgG2JOeSAqGLHEsQaBuTd/aAXcsvBfCLUb1LafyPL/v5CfBp2AZXQNHarn46+vVwn6ULC\r
+X-Received: by 10.180.19.1 with SMTP id a1mr205174wie.16.1408379605676;\r
+       Mon, 18 Aug 2014 09:33:25 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c374-75.dhcp.inet.fi.\r
+       [88.195.116.75]) by mx.google.com with ESMTPSA id\r
+       do6sm39372967wib.22.2014.08.18.09.33.23 for <multiple recipients>\r
+       (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+       Mon, 18 Aug 2014 09:33:24 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] completion: fail silently if _init_completion is not found\r
+Date: Mon, 18 Aug 2014 19:33:21 +0300\r
+Message-Id: <1408379601-31994-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 2.0.1\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 18 Aug 2014 16:33:42 -0000\r
+\r
+The completion script depends on bash-completion 1.90 or later, with\r
+_init_completion function. If that's not present, for some reason, the\r
+completion currently fails with an ugly message, messing up user's\r
+command line:\r
+\r
+$ notmuch -bash: _init_completion: command not found\r
+\r
+It's better to just not complete\r
+\r
+---\r
+\r
+This is probably unnecessary since\r
+\r
+commit aff5af582ecbacb4004ad306c6ef463d61f1ed3a\r
+Author: Jani Nikula <jani@nikula.org>\r
+Date:   Sun Feb 2 18:47:57 2014 +0200\r
+\r
+    configure: only install bash completion if supported\r
+\r
+but should not do harm.\r
+---\r
+ completion/notmuch-completion.bash | 4 ++++\r
+ 1 file changed, 4 insertions(+)\r
+\r
+diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash\r
+index d88c5e7d965e..0571dc9da8e3 100644\r
+--- a/completion/notmuch-completion.bash\r
++++ b/completion/notmuch-completion.bash\r
+@@ -395,6 +395,10 @@ _notmuch()\r
+ {\r
+     local _notmuch_commands="compact config count dump help insert new reply restore search setup show tag"\r
+     local arg cur prev words cword split\r
++\r
++    # require bash-completion with _init_completion\r
++    type -t _init_completion >/dev/null 2>&1 || return\r
++\r
+     _init_completion || return\r
\r
+     COMPREPLY=()\r
+-- \r
+2.0.1\r
+\r