Skip to content

Commit c07bd66

Browse files
committed
fix(_comp_compgen): clear the variable when no completions are generated
1 parent 24bd420 commit c07bd66

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bash_completion

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,16 @@ if ((BASH_VERSINFO[0] > 5 || BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 3)); t
863863
[[ $_dir ]] && command cd -- "$_original_pwd"
864864

865865
((${#_upvars[@]})) && _comp_unlocal "${_upvars[@]}"
866-
((${#_result[@]})) || return
866+
867+
# workaround for bash-4.2 nounset
868+
((${#_result[@]})) || {
869+
if [[ $_append ]]; then
870+
eval -- "$_var+=()"
871+
else
872+
eval -- "$_var=()"
873+
fi
874+
return
875+
}
867876

868877
if [[ $_prefix ]]; then
869878
local _i

0 commit comments

Comments
 (0)