Skip to content

Commit

Permalink
fix(_comp_get_words): empty prev if unavailable (localvar_inherit)
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Sep 24, 2023
1 parent 3c4a89c commit d8b8eef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions bash_completion
Expand Up @@ -953,9 +953,11 @@ _comp_get_words()
upvars+=("$vcword")
upargs+=(-v "$vcword" "$cword")
}
[[ $vprev && $cword -ge 1 ]] && {
[[ $vprev ]] && {
local value=""
((cword >= 1)) && value=${words[cword - 1]}
upvars+=("$vprev")
upargs+=(-v "$vprev" "${words[cword - 1]}")
upargs+=(-v "$vprev" "$value")
}
[[ $vwords ]] && {
# Note: bash < 4.4 has a bug that all the elements are connected with
Expand Down
2 changes: 1 addition & 1 deletion test/t/unit/test_unit_initialize.py
Expand Up @@ -6,7 +6,7 @@
@pytest.mark.bashcomp(
cmd=None,
ignore_env=r"^[+-](COMP(_(WORDS|CWORD|LINE|POINT)|REPLY)|"
r"cur|cword|words)=|^\+declare -f _cmd1$",
r"cur|prev|cword|words)=|^\+declare -f _cmd1$",
)
class TestUnitInitCompletion(TestUnitBase):
def test_1(self, bash):
Expand Down

0 comments on commit d8b8eef

Please sign in to comment.