about summary refs log tree commit diff
path: root/Completion/Core/compinit
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-06 09:04:32 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-06 09:04:32 +0000
commitead1fff7dbd518efdd7799030ea773cd0d5eee31 (patch)
tree86432efcfb0d5b12b22cdbefd54f64797572fbed /Completion/Core/compinit
parente2409e0649ac61e938624ba349988f58f873bf54 (diff)
downloadzsh-ead1fff7dbd518efdd7799030ea773cd0d5eee31.tar.gz
zsh-ead1fff7dbd518efdd7799030ea773cd0d5eee31.tar.xz
zsh-ead1fff7dbd518efdd7799030ea773cd0d5eee31.zip
zsh-workers/7650
Diffstat (limited to 'Completion/Core/compinit')
-rw-r--r--Completion/Core/compinit28
1 files changed, 28 insertions, 0 deletions
diff --git a/Completion/Core/compinit b/Completion/Core/compinit
index 04438327c..209ecc6e8 100644
--- a/Completion/Core/compinit
+++ b/Completion/Core/compinit
@@ -320,6 +320,34 @@ compconf() {
   fi
 }
 
+# Utility function to call a function if it exists.
+#
+# Usage: call <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.
+
+funcall() {
+  local _name _ret
+
+  [[ "$1" != (|-) ]] && _name="$1"
+
+  shift
+
+  if builtin functions "$1"; then
+    "$@"
+    _ret="$?"
+    [[ -n "$_name" ]] && eval "${_name}=${_ret}"
+    return 0
+  fi
+  return 1
+}
+
 # Now we automatically make the definition files autoloaded.
 
 typeset -U _i_files