[Pull request] Use comptopt only when available

Harmen Stoppels harmenstoppels at gmail.com
Mon Apr 3 12:34:44 CEST 2017


Hi,

MacOS currently has not support for `compopt`. Autocompletion is pretty
annoying now:

"pass D [tab] -bash: compopt: command not found"

In Docker they have had a similar issue:
https://github.com/docker/docker/pull/16492.

Below is a patch

>From 1ed0edef3c87861f209e6596694291a743d15ca4 Mon Sep 17 00:00:00 2001
From: Harmen Stoppels <harmenstoppels at gmail.com>
Date: Mon, 3 Apr 2017 11:51:54 +0200
Subject: [PATCH] Use compopt only if available

---
 src/completion/pass.bash-completion | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/completion/pass.bash-completion
b/src/completion/pass.bash-completion
index 456485b..27a46e7 100644
--- a/src/completion/pass.bash-completion
+++ b/src/completion/pass.bash-completion
@@ -54,7 +54,7 @@ _pass_complete_entries () {
     # The only time we want to add a space to the end is if there is only
     # one match, and it is not a directory
     if [[ $i -gt 1 || ( $i -eq 1 && -d $firstitem ) ]]; then
-        compopt -o nospace
+        type compopt &>/dev/null && compopt -o nospace
     fi
 }

@@ -88,7 +88,7 @@ _pass()
             init)
                 if [[ $lastarg == "-p" || $lastarg == "--path" ]]; then
                     _pass_complete_folders
-                    compopt -o nospace
+                    type compopt &>/dev/null && compopt -o nospace
                 else
                     COMPREPLY+=($(compgen -W "-p --path" -- ${cur}))
                     _pass_complete_keys
--
2.12.2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20170403/23f1de44/attachment.html>


More information about the Password-Store mailing list