summaryrefslogtreecommitdiff
path: root/Doc/Zsh/func.yo
diff options
context:
space:
mode:
authorFrank Terbeck <ft@bewatermyfriend.org>2011-12-01 10:02:04 +0100
committerFrank Terbeck <ft@bewatermyfriend.org>2011-12-01 10:02:04 +0100
commitd8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca (patch)
tree9fd9a57486ac4702608d92088ffd91f52971244f /Doc/Zsh/func.yo
parentaf2bb4fdb09414d21922d3fafe4e3a0ac1332f01 (diff)
parent9d71f4c207fb34e8d64af0443c83231b1cc3b494 (diff)
downloadzsh-d8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca.tar.gz
zsh-d8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca.zip
Merge commit 'zsh-4.3.13' into debian
Diffstat (limited to 'Doc/Zsh/func.yo')
-rw-r--r--Doc/Zsh/func.yo23
1 files changed, 17 insertions, 6 deletions
diff --git a/Doc/Zsh/func.yo b/Doc/Zsh/func.yo
index 28bc6329a..7c391f80d 100644
--- a/Doc/Zsh/func.yo
+++ b/Doc/Zsh/func.yo
@@ -158,9 +158,20 @@ If no name is given for a function, it is `anonymous' and is handled
specially. Either form of function definition may be used: a `tt(())' with
no preceding name, or a `tt(function)' with an immediately following open
brace. The function is executed immediately at the point of definition and
-is not stored for future use. The function name is set to `tt((anon))' and
-the parameter list passed to the function is empty. Note that this means
-the argument list of any enclosing script or function is hidden.
+is not stored for future use. The function name is set to `tt((anon))'.
+
+Arguments to the function may be specified as words following the
+closing brace defining the function, hence if there are none no
+arguments (other than tt($0)) are set. This is a difference from the
+way other functions are parsed: normal function definitions may be
+followed by certain keywords such as `tt(else)' or `tt(fi)', which will
+be treated as arguments to anonymous functions, so that a newline or
+semicolon is needed to force keyword interpretation.
+
+Note also that the argument list of any enclosing script or function is
+hidden (as would be the case for any other function called at this
+point).
+
Redirections may be applied to the anonymous function in the same manner as
to a current-shell structure enclosed in braces. The main use of anonymous
functions is to provide a scope for local variables. This is particularly
@@ -172,13 +183,13 @@ For example,
example(variable=outside
function {
local variable=inside
- print "I am $variable"
-}
+ print "I am $variable with arguments $*"
+} this and that
print "I am $variable")
outputs the following:
-example(I am inside
+example(I am inside with arguments this and that
I am outside)
Note that function definitions with arguments that expand to nothing,