Gave _known_hosts_real mandatory argument CWORD
The option `-h hostname' to `_known_hosts_real' is removed.
This commit is contained in:
parent
a050115f2f
commit
25e4eb6df3
@ -1036,7 +1036,7 @@ _user_at_host() {
|
||||
cur=`_get_cword`
|
||||
|
||||
if [[ $cur == *@* ]]; then
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
else
|
||||
COMPREPLY=( $( compgen -u -- "$cur" ) )
|
||||
fi
|
||||
@ -1049,24 +1049,21 @@ shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
|
||||
# `_known_hosts_real' instead.
|
||||
_known_hosts()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
cur=`_get_cword`
|
||||
|
||||
# NOTE: Passing "$@" is deprecated. See NOTE above.
|
||||
_known_hosts_real -h "$cur" "$@"
|
||||
_known_hosts_real "$@" "$(_get_cword)"
|
||||
}
|
||||
|
||||
# Helper function for completing _known_hosts.
|
||||
# This function performs host completion based on ssh's known_hosts files,
|
||||
# defaulting to standard host completion if they don't exist.
|
||||
# Arguments: -a Use aliases
|
||||
# -c Use `:' suffix
|
||||
# -F configfile Use `configfile' for configuration settings
|
||||
# -h hostname Use hostname to complete on
|
||||
# -p PREFIX Use PREFIX
|
||||
# Return: Completions are added to COMPREPLY[]
|
||||
# Usage: _known_hosts_real [OPTIONS] CWORD
|
||||
# Options: -a Use aliases
|
||||
# -c Use `:' suffix
|
||||
# -F configfile Use `configfile' for configuration settings
|
||||
# -p PREFIX Use PREFIX
|
||||
# Return: Completions, starting with CWORD, are added to COMPREPLY[]
|
||||
_known_hosts_real()
|
||||
{
|
||||
local configfile flag prefix
|
||||
@ -1075,15 +1072,16 @@ _known_hosts_real()
|
||||
local IFS=$'\n'
|
||||
|
||||
local OPTIND=1
|
||||
while getopts "acF:h:p:" flag "$@"; do
|
||||
while getopts "acF:p:" flag "$@"; do
|
||||
case $flag in
|
||||
a) aliases='yes' ;;
|
||||
c) suffix=':' ;;
|
||||
F) configfile=$OPTARG ;;
|
||||
h) cur=$OPTARG ;;
|
||||
p) prefix=$OPTARG ;;
|
||||
esac
|
||||
done
|
||||
[ $# -lt $OPTIND ] && echo "error: $FUNCNAME: missing mandatory argument CWORD"
|
||||
cur=${!OPTIND}; let "OPTIND += 1"
|
||||
[ $# -ge $OPTIND ] && echo "error: $FUNCNAME("$@"): unprocessed arguments:"\
|
||||
$(while [ $# -ge $OPTIND ]; do echo ${!OPTIND}; shift; done)
|
||||
|
||||
|
@ -17,7 +17,7 @@ have dhclient && _dhclient()
|
||||
return 0
|
||||
;;
|
||||
-s)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
@ -20,7 +20,7 @@ _arpspoof()
|
||||
return 0
|
||||
;;
|
||||
-t)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
@ -28,7 +28,7 @@ _arpspoof()
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '-i -t' -- $cur ) )
|
||||
else
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
fi
|
||||
|
||||
} &&
|
||||
@ -157,7 +157,7 @@ _sshmitm()
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '-d -I -p' -- $cur ) )
|
||||
else
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
fi
|
||||
|
||||
} &&
|
||||
@ -276,7 +276,7 @@ _webmitm()
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '-d' -- $cur ) )
|
||||
else
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
fi
|
||||
|
||||
} &&
|
||||
|
@ -50,7 +50,7 @@ _civclient()
|
||||
return 0
|
||||
;;
|
||||
-@(s|-server))
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
@ -22,7 +22,7 @@ _gkrellm()
|
||||
return 0
|
||||
;;
|
||||
-@(s|-server))
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
@ -47,7 +47,7 @@ _ktutil()
|
||||
return 0
|
||||
;;
|
||||
-a|--admin-server)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-r|--realm)
|
||||
|
@ -14,7 +14,7 @@ _ldapvi()
|
||||
|
||||
case "$prev" in
|
||||
-@(h|-host))
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-@(Y|-sasl-mech))
|
||||
|
@ -48,7 +48,7 @@ _munin-update()
|
||||
return 0
|
||||
;;
|
||||
--host)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
@ -81,7 +81,7 @@ _munin-node-configure()
|
||||
return 0
|
||||
;;
|
||||
--snmp)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
--snmpversion)
|
||||
|
@ -27,7 +27,7 @@ _ntpdate()
|
||||
COMPREPLY=( $( compgen -W '-4 -6 -b -B -d -Q -q -s -u -v -a\
|
||||
-e -k -p -o -r -t' -- $cur ) )
|
||||
else
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
fi
|
||||
} &&
|
||||
complete -F _ntpdate ntpdate
|
||||
|
@ -24,7 +24,7 @@ _ldapsearch()
|
||||
|
||||
case "$prev" in
|
||||
-h)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-H)
|
||||
@ -73,7 +73,7 @@ _ldapaddmodify()
|
||||
|
||||
case "$prev" in
|
||||
-h)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-H)
|
||||
@ -111,7 +111,7 @@ _ldapdelete()
|
||||
|
||||
case "$prev" in
|
||||
-h)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-H)
|
||||
@ -146,7 +146,7 @@ _ldapcompare()
|
||||
|
||||
case "$prev" in
|
||||
-h)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-H)
|
||||
@ -181,7 +181,7 @@ _ldapmodrdn()
|
||||
|
||||
case "$prev" in
|
||||
-h)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-H)
|
||||
@ -216,7 +216,7 @@ _ldapwhoami()
|
||||
|
||||
case "$prev" in
|
||||
-h)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-H)
|
||||
@ -250,7 +250,7 @@ _ldappasswd()
|
||||
|
||||
case "$prev" in
|
||||
-h)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-H)
|
||||
|
@ -84,7 +84,7 @@ _openssl()
|
||||
return 0
|
||||
;;
|
||||
-connect)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-starttls)
|
||||
|
@ -34,7 +34,7 @@ _createdb()
|
||||
|
||||
case "$prev" in
|
||||
-h|--host)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-U|--username|-O|--owner)
|
||||
@ -78,7 +78,7 @@ _dropdb()
|
||||
|
||||
case "$prev" in
|
||||
-h|--host)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-U|--username)
|
||||
@ -117,7 +117,7 @@ _psql()
|
||||
|
||||
case "$prev" in
|
||||
-h|--host)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
-U|--username)
|
||||
|
@ -46,7 +46,7 @@ _rdesktop()
|
||||
-A -B -e -E -m -C -D -K -S -T -N -X -a -z -x -P -r \
|
||||
-0 -4 -5' -- $cur ) )
|
||||
else
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
fi
|
||||
|
||||
} &&
|
||||
|
@ -87,7 +87,7 @@ _rsync()
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
_known_hosts_real -c -a -h "$cur"
|
||||
_known_hosts_real -c -a "$cur"
|
||||
_filedir
|
||||
;;
|
||||
esac
|
||||
|
@ -94,7 +94,7 @@ _ssh()
|
||||
fi
|
||||
shift
|
||||
done
|
||||
_known_hosts_real -a -h "$cur" $optconfigfile
|
||||
_known_hosts_real -a $optconfigfile "$cur"
|
||||
if [ $COMP_CWORD -ne 1 ]; then
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
|
||||
fi
|
||||
@ -144,7 +144,7 @@ _sftp()
|
||||
fi
|
||||
shift
|
||||
done
|
||||
_known_hosts_real -a -h "$cur" $optconfigfile
|
||||
_known_hosts_real -a $optconfigfile "$cur"
|
||||
fi
|
||||
|
||||
return 0
|
||||
@ -200,7 +200,7 @@ _scp()
|
||||
shift
|
||||
done
|
||||
|
||||
[[ "$cur" == */* ]] || _known_hosts_real -c -a -h "$cur" $optconfigfile
|
||||
[[ "$cur" == */* ]] || _known_hosts_real -c -a $optconfigfile "$cur"
|
||||
|
||||
# This approach is used instead of _filedir to get a space appended
|
||||
# after local file/dir completions, and $nospace retained for others.
|
||||
@ -233,7 +233,7 @@ _ssh_copy_id() {
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '-i' -- $cur ) )
|
||||
else
|
||||
_known_hosts_real -a -h "$cur"
|
||||
_known_hosts_real -a "$cur"
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
@ -41,7 +41,7 @@ _tightvncviewer()
|
||||
return 0
|
||||
;;
|
||||
-via)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
@ -54,7 +54,7 @@ _tightvncviewer()
|
||||
-compresslevel -quality -nojpeg -nocursorshape \
|
||||
-x11cursor' -- $cur ) )
|
||||
else
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
fi
|
||||
} &&
|
||||
complete -F _tightvncviewer tightvncviewer
|
||||
@ -85,7 +85,7 @@ _xvnc4viewer()
|
||||
;;
|
||||
# -via
|
||||
-[vV][iI][aA])
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
@ -121,7 +121,7 @@ _xvnc4viewer()
|
||||
)" -- "$(echo "$cur" | tr [:upper:] [:lower:])" ) )
|
||||
fi
|
||||
else
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
fi
|
||||
} &&
|
||||
complete -F _xvnc4viewer xvnc4viewer
|
||||
|
@ -27,7 +27,7 @@ _vpnc()
|
||||
return 0
|
||||
;;
|
||||
--gateway)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
@ -9,9 +9,9 @@ _xhost ()
|
||||
local cur=`_get_cword`
|
||||
|
||||
case "$cur" in
|
||||
+*) _known_hosts_real -h "${cur:1}" -p+ ;;
|
||||
-*) _known_hosts_real -h "${cur:1}" -p- ;;
|
||||
*) _known_hosts_real -h "$cur" ;;
|
||||
+*) _known_hosts_real -p+ "${cur:1}" ;;
|
||||
-*) _known_hosts_real -p- "${cur:1}" ;;
|
||||
*) _known_hosts_real "$cur" ;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
|
@ -97,7 +97,7 @@ _xm()
|
||||
_xen_domain_names
|
||||
;;
|
||||
3)
|
||||
_known_hosts_real -h "$cur"
|
||||
_known_hosts_real "$cur"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
@ -19,7 +19,7 @@ lappend hosts doo gee hus ike
|
||||
set hosts [lsort -ascii $hosts]
|
||||
set hosts [join $hosts "\\s+"]
|
||||
# Call _known_hosts
|
||||
set cmd {_known_hosts -aF fixtures/_known_hosts_real/config; echo_array COMPREPLY}
|
||||
set cmd {_known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
|
||||
send "$cmd\r"
|
||||
expect -ex "$cmd\r\n"
|
||||
expect {
|
||||
@ -41,7 +41,7 @@ lappend hosts gee hus doo ike two
|
||||
set hosts [lsort -ascii $hosts]
|
||||
set hosts [join $hosts "\\s+"]
|
||||
# Call _known_hosts
|
||||
set cmd {_known_hosts_real -aF 'fixtures/_known_hosts_real/spaced conf'; echo_array COMPREPLY}
|
||||
set cmd {_known_hosts_real -aF 'fixtures/_known_hosts_real/spaced conf' ''; echo_array COMPREPLY}
|
||||
send "$cmd\r"
|
||||
expect -ex "$cmd\r\n"
|
||||
expect {
|
||||
|
Loading…
x
Reference in New Issue
Block a user