Skip to content

Commit 40235a3

Browse files
committed
fix(_comp_finalize): avoid negative indices in unset for bash 4.2
1 parent ac2112d commit 40235a3

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
@@ -1000,8 +1000,11 @@ _comp_finalize()
10001000
fi
10011001
fi
10021002

1003-
unset -v '_comp_finalize__depth[-1]'
1004-
unset -v '_comp_finalize__target[-1]'
1003+
# Note: bash 4.2 does not support negative array indices with `unset`
1004+
# like `unset -v 'arr[-1]'` even when the array has at least one
1005+
# element. It is supported in bash 4.3.
1006+
unset -v '_comp_finalize__depth[${#_comp_finalize__depth[@]}-1]'
1007+
unset -v '_comp_finalize__target[${#_comp_finalize__target[@]}-1]'
10051008
if ((${#_comp_finalize__depth[@]} == 0)); then
10061009
eval -- "${_comp_finalize__original_return_trap:-trap - RETURN}"
10071010
_comp_finalize__original_return_trap=

0 commit comments

Comments
 (0)