From a8a9284250556f5893fc54d4a776845b20151d90 Mon Sep 17 00:00:00 2001
From: grahamlyons <graham@grahamlyons.com>
Date: Fri, 8 Sep 2017 12:06:40 +0100
Subject: [PATCH] Test for `compopt` presence before using

In bash 3.x, the default on OSX, `compopt` doesn't exist so errors
are seen when using tab completion. This tests for the presence of
the command first before using it, falling back to doing nothing,
which still works OK.
---
 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..cb50010 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.11.0 (Apple Git-81)

