Skip to content

Commit b6a67f6

Browse files
committed
fix(_comp_finalize): avoid negative indices in unset for bash 4.2
1 parent ec17753 commit b6a67f6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

bash_completion

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,11 @@ _comp_finalize()
10061006
fi
10071007
fi
10081008

1009-
unset -v '_comp_finalize__depth[-1]'
1010-
unset -v '_comp_finalize__target[-1]'
1009+
# Note: bash 4.2 does not support negative array indices with `unset`
1010+
# like `unset -v 'arr[-1]'` even when the array has at least one
1011+
# element. It is supported in bash 4.3.
1012+
unset -v '_comp_finalize__depth[${#_comp_finalize__depth[@]}-1]'
1013+
unset -v '_comp_finalize__target[${#_comp_finalize__target[@]}-1]'
10111014
if ((${#_comp_finalize__depth[@]} == 0)); then
10121015
eval -- "${_comp_finalize__original_return_trap:-trap - RETURN}"
10131016
_comp_finalize__original_return_trap=

0 commit comments

Comments
 (0)