Skip to content

Commit c977f0b

Browse files
committed
fix(scp): fix a bug that -F<prefix>[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`.
1 parent c298dcf commit c977f0b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

completions/ssh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,13 @@ _comp_xfunc_scp_compgen_local_files()
547547
local files
548548
_comp_expand_glob files '"$cur"*' || return 0
549549
if [[ $_dirsonly ]]; then
550-
_comp_compgen -U files split -l -- "$(
550+
_comp_compgen -RU files split -l -- "$(
551551
command ls -aF1dL "${files[@]}" 2>/dev/null |
552552
command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \
553553
-e '/[^\/]$/d' -e "s/^/${1-}/"
554554
)"
555555
else
556-
_comp_compgen -U files split -l -- "$(
556+
_comp_compgen -RU files split -l -- "$(
557557
command ls -aF1dL "${files[@]}" 2>/dev/null |
558558
command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \
559559
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' -e "s/^/${1-}/"

test/t/test_scp.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ def test_capital_f_without_space(self, completion):
5555
"option requires an argument -- F" in x for x in completion
5656
)
5757

58+
@pytest.mark.complete("scp -Fconf", cwd="scp")
59+
def test_capital_f_without_space_2(self, completion):
60+
assert completion == "ig"
61+
62+
@pytest.mark.complete("scp -Fbi", cwd="scp")
63+
def test_capital_f_without_space_3(self, completion):
64+
assert completion == "n/"
65+
5866
@pytest.fixture(scope="class")
5967
def live_pwd(self, bash):
6068
try:

0 commit comments

Comments
 (0)