diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-11-18 10:05:45 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-11-18 10:05:45 +0000 |
commit | 6f50f016747f878b480c3ee109e4fcf6c87a2fff (patch) | |
tree | 47277b85d21cd58cec6340c0fe0e8c07cb58c14d /Completion/Core | |
parent | 7df71329cf11a6ab295e6213db4020215a839d65 (diff) | |
download | zsh-6f50f016747f878b480c3ee109e4fcf6c87a2fff.tar.gz zsh-6f50f016747f878b480c3ee109e4fcf6c87a2fff.tar.xz zsh-6f50f016747f878b480c3ee109e4fcf6c87a2fff.zip |
Initial revision
Diffstat (limited to 'Completion/Core')
-rw-r--r-- | Completion/Core/_funcall | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Completion/Core/_funcall b/Completion/Core/_funcall new file mode 100644 index 000000000..540f8ae83 --- /dev/null +++ b/Completion/Core/_funcall @@ -0,0 +1,32 @@ +#autoload + +# Utility function to call a function if it exists. +# +# Usage: _funcall <return> <name> [ <args> ... ] +# +# If a function named <name> is defined (or defined to be autoloaded), +# it is called. If <return> is given not the string `-' or empty, it is +# taken as the name of a parameter and the return status of the function +# called is stored in this parameter. All other arguments are given +# to the function called. +# The return value of this function is zero if the function was +# called and non-zero otherwise. + +local _name _ret + +[[ "$1" != (|-) ]] && _name="$1" + +shift + +if (( $+functions[$1] )); then + "$@" + _ret="$?" + + [[ -n "$_name" ]] && eval "${_name}=${_ret}" + + compstate[restore]='' + + return 0 +fi + +return 1 |