Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,8 @@ if ((BASH_VERSINFO[0] > 5 || BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 3)); t
# pat, the effect of -X '' is overwritten by the specified one.
IFS=$_ifs compgen -V _result -X '' "$@" ${_cur:+-- "$_cur"} || {
_comp_compgen__error_fallback
# shellcheck disable=SC2164
[[ $_dir ]] && command cd -- "$_original_pwd"
return
}

Expand Down
6 changes: 6 additions & 0 deletions test/config/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ add_comp_wordbreak_char()

_comp__test_get_env()
{
# Note: PWD is supposed to reflect the current working directory, but the
# real current working directory of the process can be different, e.g. when
# PWD is manually altered. Therefore, we also check the result of $(pwd)
# explicitly via a new variable `_comp_test_pwd`.
local _comp_test_pwd=$(pwd)

(
# Do not output the state of test variables "_comp__test_+([0-9])_*"
# and internal mutable variables "_comp_*_mut_*".
Expand Down
9 changes: 9 additions & 0 deletions test/t/unit/test_unit_compgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def functions(self, bash):
'_comp__test_words_ifs() { local input=$2; _comp__test_compgen -F "$1" -c "${@:$#}" -- -W \'$input\'; }',
)

assert_bash_exec(
bash,
'_comp_cmd_fb() { _comp_compgen -c "$(_get_cword)" -C _filedir -- -f; }; '
"complete -F _comp_cmd_fb fb",
)
assert_bash_exec(
bash,
'_comp_cmd_fc() { _comp_compgen -c "$(_get_cword)" -C _filedir filedir; }; '
Expand Down Expand Up @@ -143,6 +148,10 @@ def test_6_option_C_4(self, functions, completion):
# will not suffix a slash to the directory name.
assert completion == "b"

@pytest.mark.complete(r"fb nonexistent")
def test_6_option_C_5(self, bash, functions, completion):
assert not completion

def test_7_icmd(self, bash, functions):
with bash_env_saved(bash) as bash_env:
bash_env.write_variable(
Expand Down
Loading