Skip to content

Commit

Permalink
scp, sftp, ssh: fix completion on options bundled with -4/-6
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed May 23, 2020
1 parent 50ad3f8 commit b4490f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
36 changes: 18 additions & 18 deletions completions/ssh
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,6 @@ _ssh()
local ipvx

case $prev in
-*4*)
ipvx=-4
;;
-*6*)
ipvx=-6
;;
-*b)
_ip_addresses
return
Expand Down Expand Up @@ -309,6 +303,12 @@ _ssh()
_available_interfaces
return
;;
-*4*)
ipvx=-4
;;
-*6*)
ipvx=-6
;;
esac

if [[ $cur == -F* ]]; then
Expand Down Expand Up @@ -347,12 +347,6 @@ _sftp()
local ipvx

case $prev in
-*4*)
ipvx=-4
;;
-*6*)
ipvx=-6
;;
-*[BDlPRs])
return
;;
Expand Down Expand Up @@ -381,6 +375,12 @@ _sftp()
COMPREPLY=($(compgen -c -- "$cur"))
return
;;
-*4*)
ipvx=-4
;;
-*6*)
ipvx=-6
;;
esac

if [[ $cur == -F* ]]; then
Expand Down Expand Up @@ -484,12 +484,6 @@ _scp()
local ipvx

case $prev in
-*4*)
ipvx=-4
;;
-*6*)
ipvx=-6
;;
-*c)
_ssh_ciphers
COMPREPLY=("${COMPREPLY[@]/%/ }")
Expand Down Expand Up @@ -521,6 +515,12 @@ _scp()
COMPREPLY=($(compgen -c -- "$cur"))
return
;;
-*4*)
ipvx=-4
;;
-*6*)
ipvx=-6
;;
esac

_expand || return
Expand Down
5 changes: 5 additions & 0 deletions test/t/test_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ def test_partial_hostname(self, bash, known_hosts):
first_char, partial_hosts = partialize(bash, known_hosts)
completion = assert_complete(bash, "ssh %s" % first_char)
assert completion == partial_hosts

@pytest.mark.parametrize("protocol", "4 6 9".split())
def test_protocol_option_bundling(self, bash, protocol):
completion = assert_complete(bash, "ssh -%sF ssh/" % protocol)
assert "config" in completion

0 comments on commit b4490f2

Please sign in to comment.