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
|
return 0
|
||||||
;;
|
;;
|
||||||
--root)
|
--root)
|
||||||
type _cvs_roots &>/dev/null && _cvs_roots
|
declare -F _cvs_roots &>/dev/null && _cvs_roots
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -55,7 +55,7 @@ _cvsps()
|
|||||||
--cvs-direct --no-cvs-direct --debuglvl -Z --root -q -A' \
|
--cvs-direct --no-cvs-direct --debuglvl -Z --root -q -A' \
|
||||||
-- "$cur" ) )
|
-- "$cur" ) )
|
||||||
else
|
else
|
||||||
type _cvs_roots &>/dev/null && _cvs_roots
|
declare -F _cvs_roots &>/dev/null && _cvs_roots
|
||||||
fi
|
fi
|
||||||
} &&
|
} &&
|
||||||
complete -F _cvsps cvsps
|
complete -F _cvsps cvsps
|
||||||
|
@ -48,7 +48,7 @@ _portinstall()
|
|||||||
complete -F _portinstall -o dirnames portinstall
|
complete -F _portinstall -o dirnames portinstall
|
||||||
|
|
||||||
# _pkg_delete is in pkg_install
|
# _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
|
complete -F _pkg_delete -o dirnames pkg_deinstall
|
||||||
|
|
||||||
# Local variables:
|
# Local variables:
|
||||||
|
@ -72,7 +72,7 @@ _rsync()
|
|||||||
compopt +o nospace
|
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
|
# find which remote shell is used
|
||||||
local i shell=ssh
|
local i shell=ssh
|
||||||
for (( i=1; i < cword; i++ )); do
|
for (( i=1; i < cword; i++ )); do
|
||||||
@ -86,7 +86,8 @@ _rsync()
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
_known_hosts_real -c -a "$cur"
|
_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
|
esac
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ _sshfs()
|
|||||||
|
|
||||||
_expand || return 0
|
_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
|
_scp_remote_files -d
|
||||||
# unlike scp and rsync, sshfs works with 1 backslash instead of 3
|
# unlike scp and rsync, sshfs works with 1 backslash instead of 3
|
||||||
COMPREPLY=( "${COMPREPLY[@]//\\\\\\/\\}" )
|
COMPREPLY=( "${COMPREPLY[@]//\\\\\\/\\}" )
|
||||||
@ -20,7 +20,7 @@ _sshfs()
|
|||||||
|
|
||||||
[[ "$cur" == */* ]] || _known_hosts_real -c -a "$cur"
|
[[ "$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
|
return 0
|
||||||
} &&
|
} &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user