From a47bd375bb0f95dc6d388d4097c420bddb72ae33 Mon Sep 17 00:00:00 2001 From: John Swinbank Date: Wed, 9 May 2018 22:17:01 -0700 Subject: [PATCH 059/352] _xspecs: Declare as global on bash >= 4.2 By default, associative arrays are local. If bash_completion is sourced from within a function, they won't propagate to the caller, and the system is not initialized properly. By making this explicitly global, it propagates as expected. bash >= 4.2 only, because of declare -g support. Closes #210 --- bash_completion | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bash_completion b/bash_completion index 442c075..3884850 100644 --- a/bash_completion +++ b/bash_completion @@ -1891,7 +1891,13 @@ complete -F _longopt a2ps awk base64 bash bc bison cat chroot colordiff cp \ sed seq sha{,1,224,256,384,512}sum shar sort split strip sum tac tail tee \ texindex touch tr uname unexpand uniq units vdir wc who -declare -A _xspecs +# declare only knows -g in bash >= 4.2. +if [[ ${BASH_VERSINFO[0]} -gt 4 || + ${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -ge 2 ]]; then + declare -Ag _xspecs +else + declare -A _xspecs +fi _filedir_xspec() { local cur prev words cword -- 1.8.3.1