[Bash-completion-commits] [bash-completion] 02/03: ssh: Query ciphers and macs from ssh before hardcoded fallback
Ville Skyttä
scop-guest at moszumanska.debian.org
Sun Jun 28 21:09:59 UTC 2015
This is an automated email from the git hooks/post-receive script.
scop-guest pushed a commit to branch master
in repository bash-completion.
commit cf4c7ebf6c754028957fe0061d0ed247a47ecb1c
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Mon Jun 29 00:02:12 2015 +0300
ssh: Query ciphers and macs from ssh before hardcoded fallback
---
completions/ssh | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/completions/ssh b/completions/ssh
index 69d1e3c..7cd1c86 100644
--- a/completions/ssh
+++ b/completions/ssh
@@ -6,17 +6,26 @@ _ssh_queries()
"cipher cipher-auth mac kex key protocol-version" -- "$cur" ) )
}
+_ssh_query()
+{
+ ${1:-ssh} -Q $2 2>/dev/null
+}
+
_ssh_ciphers()
{
- COMPREPLY+=( $( compgen -W '3des-cbc aes128-cbc aes192-cbc aes256-cbc
+ local ciphers="$( _ssh_query $1 cipher )"
+ [[ $ciphers ]] || ciphers="3des-cbc aes128-cbc aes192-cbc aes256-cbc
aes128-ctr aes192-ctr aes256-ctr arcfour128 arcfour256 arcfour
- blowfish-cbc cast128-cbc' -- "$cur" ) )
+ blowfish-cbc cast128-cbc"
+ COMPREPLY+=( $( compgen -W "$ciphers" -- "$cur" ) )
}
_ssh_macs()
{
- COMPREPLY+=( $( compgen -W 'hmac-md5 hmac-sha1 umac-64 at openssh.com
- hmac-ripemd160 hmac-sha1-96 hmac-md5-96' -- "$cur" ) )
+ local macs="$( _ssh_query $1 mac )"
+ [[ $macs ]] || macs="hmac-md5 hmac-sha1 umac-64 at openssh.com hmac-ripemd160
+ hmac-sha1-96 hmac-md5-96"
+ COMPREPLY+=( $( compgen -W "$macs" -- "$cur" ) )
}
_ssh_options()
@@ -45,7 +54,8 @@ _ssh_options()
}
# Complete a ssh suboption (like ForwardAgent=y<tab>)
-# Only one parameter: the string to complete including the equal sign.
+# Two parameters: the string to complete including the equal sign, and
+# the ssh executable to invoke (optional).
# Not all suboptions are completed.
# Doesn't handle comma-separated lists.
_ssh_suboption()
@@ -95,10 +105,10 @@ _ssh_suboption()
keyboard-interactive password' -- "$cur" ) )
;;
MACs)
- _ssh_macs
+ _ssh_macs "$2"
;;
Ciphers)
- _ssh_ciphers
+ _ssh_ciphers "$2"
;;
esac
return 0
@@ -112,7 +122,7 @@ _ssh_suboption_check()
# Get prev and cur words without splitting on =
local cureq=`_get_cword :=` preveq=`_get_pword :=`
if [[ $cureq == *=* && $preveq == -o ]]; then
- _ssh_suboption $cureq
+ _ssh_suboption $cureq "$1"
return $?
fi
return 1
@@ -126,7 +136,7 @@ _ssh()
local configfile
local -a config
- _ssh_suboption_check && return 0
+ _ssh_suboption_check "$1" && return 0
case $prev in
-F|-i|-S)
@@ -134,11 +144,11 @@ _ssh()
return 0
;;
-c)
- _ssh_ciphers
+ _ssh_ciphers "$1"
return 0
;;
-m)
- _ssh_macs
+ _ssh_macs "$1"
return 0
;;
-l)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/bash-completion/bash-completion.git
More information about the Bash-completion-commits
mailing list