Use "declare -F" instead of "type" to check for function existence.
Avoids some stat() calls when it doesn't exist.
This commit is contained in:
parent
ea90dc1a86
commit
f8d8444667
@ -44,7 +44,7 @@ _cvsps()
|
||||
return 0
|
||||
;;
|
||||
--root)
|
||||
type _cvs_roots &>/dev/null && _cvs_roots
|
||||
declare -F _cvs_roots &>/dev/null && _cvs_roots
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
@ -55,7 +55,7 @@ _cvsps()
|
||||
--cvs-direct --no-cvs-direct --debuglvl -Z --root -q -A' \
|
||||
-- "$cur" ) )
|
||||
else
|
||||
type _cvs_roots &>/dev/null && _cvs_roots
|
||||
declare -F _cvs_roots &>/dev/null && _cvs_roots
|
||||
fi
|
||||
} &&
|
||||
complete -F _cvsps cvsps
|
||||
|
@ -48,7 +48,7 @@ _portinstall()
|
||||
complete -F _portinstall -o dirnames portinstall
|
||||
|
||||
# _pkg_delete is in pkg_install
|
||||
type _pkg_delete &>/dev/null && have pkg_deinstall && \
|
||||
declare -F _pkg_delete &>/dev/null && have pkg_deinstall && \
|
||||
complete -F _pkg_delete -o dirnames pkg_deinstall
|
||||
|
||||
# Local variables:
|
||||
|
@ -72,7 +72,7 @@ _rsync()
|
||||
compopt +o nospace
|
||||
;;
|
||||
*:*)
|
||||
if type _scp_remote_files &>/dev/null; then
|
||||
if declare -F _scp_remote_files &>/dev/null; then
|
||||
# find which remote shell is used
|
||||
local i shell=ssh
|
||||
for (( i=1; i < cword; i++ )); do
|
||||
@ -86,7 +86,8 @@ _rsync()
|
||||
;;
|
||||
*)
|
||||
_known_hosts_real -c -a "$cur"
|
||||
type _scp_local_files &>/dev/null && _scp_local_files || _filedir
|
||||
declare -F _scp_local_files &>/dev/null && \
|
||||
_scp_local_files || _filedir
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -11,7 +11,7 @@ _sshfs()
|
||||
|
||||
_expand || return 0
|
||||
|
||||
if [[ "$cur" == *:* ]] && type _scp_remote_files &>/dev/null ; then
|
||||
if [[ "$cur" == *:* ]] && declare -F _scp_remote_files &>/dev/null ; then
|
||||
_scp_remote_files -d
|
||||
# unlike scp and rsync, sshfs works with 1 backslash instead of 3
|
||||
COMPREPLY=( "${COMPREPLY[@]//\\\\\\/\\}" )
|
||||
@ -20,7 +20,7 @@ _sshfs()
|
||||
|
||||
[[ "$cur" == */* ]] || _known_hosts_real -c -a "$cur"
|
||||
|
||||
type _scp_local_files &>/dev/null && _scp_local_files -d
|
||||
declare -F _scp_local_files &>/dev/null && _scp_local_files -d
|
||||
|
||||
return 0
|
||||
} &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user