about summary refs log tree commit diff
path: root/Doc/Zsh/builtins.yo
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2017-03-01 10:01:01 +0000
committerPeter Stephenson <pws@zsh.org>2017-03-01 10:01:01 +0000
commit47c05f6b66ebd071a60a76158d7f51d4b49c25a2 (patch)
tree90e0ba26983d2ce22f5ecd317aa621bbf07b7f6e /Doc/Zsh/builtins.yo
parent24497ad19624ae7de173c4276134365f67698299 (diff)
downloadzsh-47c05f6b66ebd071a60a76158d7f51d4b49c25a2.tar.gz
zsh-47c05f6b66ebd071a60a76158d7f51d4b49c25a2.tar.xz
zsh-47c05f6b66ebd071a60a76158d7f51d4b49c25a2.zip
40622 with typos fixed: functions -Ms.
This adds the capability for mathematical functions based on shell
functions to have a string argument.  Module functions have had
this for a long time.
Diffstat (limited to 'Doc/Zsh/builtins.yo')
-rw-r--r--Doc/Zsh/builtins.yo16
1 files changed, 15 insertions, 1 deletions
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index bdd1ad1bb..37e386581 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -840,7 +840,7 @@ point numbers are not permitted.
 )
 findex(functions)
 xitem(tt(functions) [ {tt(PLUS())|tt(-)}tt(UkmtTuWz) ] [ tt(-x) var(num) ] [ var(name) ... ])
-xitem(tt(functions -M) var(mathfn) [ var(min) [ var(max) [ var(shellfn) ] ] ])
+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),
@@ -882,6 +882,13 @@ The result of the last arithmetical expression evaluated
 inside the shell function (even if it is a form that normally only returns
 a status) gives the result of the mathematical function.
 
+If the additional option tt(-s) is given to tt(functions -M), the
+argument to the function is a single string: anything between the
+opening and matching closing parenthesis is passed to the function as a
+single argument, even if it includes commas or white space.  The minimum
+and maximum argument specifiers must therefore be 1 if given.  An empty
+argument list is passed as a zero-length string.
+
 tt(functions -M) with no arguments lists all such user-defined functions in
 the same form as a definition.  With the additional option tt(-m) and
 a list of arguments, all functions whose var(mathfn) matches one of
@@ -898,6 +905,13 @@ For example, the following prints the cube of 3:
 example(zmath_cube+LPAR()RPAR() { (( $1 * $1 * $1 )) }
 functions -M cube 1 1 zmath_cube
 print $(( cube+LPAR()3+RPAR() )))
+
+The following string function takes a single argument, including
+the commas, so prints 11:
+
+example(stringfn+LPAR()RPAR() { (( $#1 )) }
+functions -Ms stringfn
+print $(( stringfn+LPAR()foo,bar,rod+RPAR() )))
 )
 module(getcap)(zsh/cap)
 findex(getln)