From 85b8e8ea89dd7d19f68e80b1a1402ca3943e2975 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 5 Apr 2025 13:08:25 +0900 Subject: [PATCH] fix(scp): fix a bug that `-F[TAB]` did not complete at all This was because the filtering by a modified `cur` is performed after prefixing "-F". Since we generate the filenames starting with "$cur", we do not need to further filter the results with `cur`. We disable the filtering by specifying the `-R` flag to `_comp_compgen`. --- completions/ssh | 4 ++-- test/t/test_scp.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/completions/ssh b/completions/ssh index b8e84b38f88..db30ba340f7 100644 --- a/completions/ssh +++ b/completions/ssh @@ -547,13 +547,13 @@ _comp_xfunc_scp_compgen_local_files() local files _comp_expand_glob files '"$cur"*' || return 0 if [[ $_dirsonly ]]; then - _comp_compgen -U files split -l -- "$( + _comp_compgen -RU files split -l -- "$( command ls -aF1dL "${files[@]}" 2>/dev/null | command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \ -e '/[^\/]$/d' -e "s/^/${1-}/" )" else - _comp_compgen -U files split -l -- "$( + _comp_compgen -RU files split -l -- "$( command ls -aF1dL "${files[@]}" 2>/dev/null | command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \ -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' -e "s/^/${1-}/" diff --git a/test/t/test_scp.py b/test/t/test_scp.py index 93766c002a7..3bfbfff69f2 100644 --- a/test/t/test_scp.py +++ b/test/t/test_scp.py @@ -58,6 +58,14 @@ def test_capital_f_without_space(self, completion): "option requires an argument -- F" in x for x in completion ) + @pytest.mark.complete("scp -Fconf", cwd="scp") + def test_capital_f_without_space_2(self, completion): + assert completion == "ig" + + @pytest.mark.complete("scp -Fbi", cwd="scp") + def test_capital_f_without_space_3(self, completion): + assert completion == "n/" + @pytest.fixture(scope="class") def live_pwd(self, bash): try: