Skip "bash: declare: -A: invalid option" error gracefully

The use of "declare -A flaghash" (associative array) was introduced
in PR #205, which works perfectly for Bash 4.x, but OS X insists on
shipping a very outdated Bash 3.2.x.

This patch hides the "bash: declare: -A: invalid option" error message
and allows the bash completion script to continue gracefully on
OS X, albeit without the benefit of the new feature in PR #205.

Fixes #240
This commit is contained in:
Anthony Fok 2016-02-05 13:04:36 +08:00
parent 8e91712f17
commit 801364aa15

View File

@ -219,7 +219,7 @@ func postscript(w io.Writer, name string) error {
}
_, err = fmt.Fprintf(w, `{
local cur prev words cword
declare -A flaghash
declare -A flaghash 2>/dev/null || :
if declare -F _init_completion >/dev/null 2>&1; then
_init_completion -s || return
else