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