about summary refs log tree commit diff
path: root/Doc
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2019-04-10 20:54:52 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2019-08-03 19:53:51 +0100
commit4fae52572699770fdf4af6bc94d8b219cb401ad2 (patch)
tree30354f47cdda0b36eda1c6149549cb79064d16a6 /Doc
parente0d063a2ade821baf570eb300d4be93692b494f8 (diff)
downloadzsh-4fae52572699770fdf4af6bc94d8b219cb401ad2.tar.gz
zsh-4fae52572699770fdf4af6bc94d8b219cb401ad2.tar.xz
zsh-4fae52572699770fdf4af6bc94d8b219cb401ad2.zip
Copy functions using functions -c old new.
Documentation and test.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/Zsh/builtins.yo11
1 files changed, 10 insertions, 1 deletions
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index d7b6e88fa..9eee30d46 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -858,10 +858,11 @@ point numbers are not permitted.
 )
 findex(functions)
 xitem(tt(functions) [ {tt(PLUS())|tt(-)}tt(UkmtTuWz) ] [ tt(-x) var(num) ] [ var(name) ... ])
+xitem(tt(functions -c) var(oldfn) var(newfn))
 xitem(tt(functions -M) [tt(-s)] var(mathfn) [ var(min) [ var(max) [ var(shellfn) ] ] ])
 xitem(tt(functions -M) [ tt(-m) var(pattern) ... ])
 item(tt(functions +M) [ tt(-m) ] var(mathfn) ... )(
-Equivalent to tt(typeset -f), with the exception of the tt(-x),
+Equivalent to tt(typeset -f), with the exception of the tt(-c), tt(-x),
 tt(-M) and tt(-W) options.  For tt(functions -u) and tt(functions -U),
 see tt(autoload), which provides additional options.
 
@@ -875,6 +876,14 @@ function or functions only.  The option is turned off at the start of
 nested functions (apart from anonoymous functions) unless the called
 function also has the tt(-W) attribute.
 
+The tt(-c) option causes var(oldfn) to be copied to var(newfn).  The
+copy is efficiently handled internally by reference counting.  If
+var(oldfn) was marked for autoload it is first loaded and if this
+fails the copy fails.  Either function may subsequently be redefined
+without affecting the other.  A typical idiom is that var(oldfn) is the
+name of a library shell function which is then redefined to call
+tt(newfn), thereby installing a modified version of the function.
+
 Use of the tt(-M) option may not be combined with any of the options
 handled by tt(typeset -f).