Skip to content

Commit e29517d

Browse files
committed
fix(ssh): do not complete commands if hostnames haven't been specified
1 parent 72b234a commit e29517d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

completions/ssh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,14 @@ _ssh()
332332
elif [[ $cur == -* ]]; then
333333
COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
334334
else
335-
_known_hosts_real ${ipvx-} -a ${configfile:+-F "$configfile"} -- "$cur"
336-
337335
local args
338336
_count_args "=" "-*[bcDeLpRWEFSiIJlmOoQw]"
339337
if ((args > 1)); then
340338
compopt -o filenames
341339
COMPREPLY+=($(compgen -c -- "$cur"))
340+
else
341+
_known_hosts_real ${ipvx-} -a ${configfile:+-F "$configfile"} \
342+
-- "$cur"
342343
fi
343344
fi
344345
} &&

test/t/test_ssh.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ def test_1(self, completion):
1010

1111
@pytest.mark.complete("ssh -F config ls", cwd="ssh")
1212
def test_2(self, completion):
13-
"""Should complete both commands and hostname."""
14-
assert all(x in completion for x in "ls ls_known_host".split())
13+
"""
14+
Should not complete commands when host is not specified.
15+
16+
Test sanity assumes there are commands starting with `ls`.
17+
"""
18+
assert completion == "_known_host"
1519

1620
@pytest.mark.complete("ssh bash", cwd="ssh")
1721
def test_3(self, completion):

0 commit comments

Comments
 (0)