summaryrefslogtreecommitdiff
path: root/Doc/help/functions
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2022-05-14 23:32:19 +0200
committerAxel Beckert <abe@deuxchevaux.org>2022-05-14 23:32:19 +0200
commitd4d203488826181aa4eb360ce57de138417ba680 (patch)
tree5f2939130b24381b6d8b11eec7573732eb52317a /Doc/help/functions
parent9529af723604dfe1c8152db11e1d216621c898d5 (diff)
parent73d317384c9225e46d66444f93b46f0fbe7084ef (diff)
downloadzsh-d4d203488826181aa4eb360ce57de138417ba680.tar.gz
zsh-d4d203488826181aa4eb360ce57de138417ba680.zip
New upstream version 5.9
Diffstat (limited to 'Doc/help/functions')
-rw-r--r--Doc/help/functions81
1 files changed, 41 insertions, 40 deletions
diff --git a/Doc/help/functions b/Doc/help/functions
index cadbd0350..37472368f 100644
--- a/Doc/help/functions
+++ b/Doc/help/functions
@@ -5,23 +5,24 @@ functions -M [ -m pattern ... ]
functions +M [ -m ] mathfn ...
Equivalent to typeset -f, with the exception of the -c, -x, -M
and -W options. For functions -u and functions -U, see au-
- toload, which provides additional options.
+ toload, which provides additional options. For functions -t and
+ functions -T, see typeset -f.
The -x option indicates that any functions output will have each
- leading tab for indentation, added by the shell to show syntac-
- tic structure, expanded to the given number num of spaces. num
+ leading tab for indentation, added by the shell to show syntac-
+ tic structure, expanded to the given number num of spaces. num
can also be 0 to suppress all indentation.
- The -W option turns on the option WARN_NESTED_VAR for the named
- function or functions only. The option is turned off at the
- start of nested functions (apart from anonoymous functions) un-
+ The -W option turns on the option WARN_NESTED_VAR for the named
+ function or functions only. The option is turned off at the
+ start of nested functions (apart from anonoymous functions) un-
less the called function also has the -W attribute.
- The -c option causes oldfn to be copied to newfn. The copy is
- efficiently handled internally by reference counting. If oldfn
+ The -c option causes oldfn to be copied to newfn. The copy is
+ efficiently handled internally by reference counting. If oldfn
was marked for autoload it is first loaded and if this fails the
copy fails. Either function may subsequently be redefined with-
- out affecting the other. A typical idiom is that oldfn is the
+ out affecting the other. A typical idiom is that oldfn is the
name of a library shell function which is then redefined to call
newfn, thereby installing a modified version of the function.
@@ -31,30 +32,30 @@ functions +M [ -m ] mathfn ...
handled by typeset -f.
functions -M mathfn defines mathfn as the name of a mathematical
- function recognised in all forms of arithmetical expressions;
- see the section `Arithmetic Evaluation' in zshmisc(1). By de-
- fault mathfn may take any number of comma-separated arguments.
- If min is given, it must have exactly min args; if min and max
- are both given, it must have at least min and at most max args.
+ function recognised in all forms of arithmetical expressions;
+ see the section `Arithmetic Evaluation' in zshmisc(1). By de-
+ fault mathfn may take any number of comma-separated arguments.
+ If min is given, it must have exactly min args; if min and max
+ are both given, it must have at least min and at most max args.
max may be -1 to indicate that there is no upper limit.
- By default the function is implemented by a shell function of
- the same name; if shellfn is specified it gives the name of the
- corresponding shell function while mathfn remains the name used
- in arithmetical expressions. The name of the function in $0 is
- mathfn (not shellfn as would usually be the case), provided the
+ By default the function is implemented by a shell function of
+ the same name; if shellfn is specified it gives the name of the
+ corresponding shell function while mathfn remains the name used
+ in arithmetical expressions. The name of the function in $0 is
+ mathfn (not shellfn as would usually be the case), provided the
option FUNCTION_ARGZERO is in effect. The positional parameters
- in the shell function correspond to the arguments of the mathe-
+ in the shell function correspond to the arguments of the mathe-
matical function call.
- The result of the last arithmetical expression evaluated inside
- the shell function gives the result of the mathematical func-
- tion. This is not limited to arithmetic substitutions of the
+ The result of the last arithmetical expression evaluated inside
+ the shell function gives the result of the mathematical func-
+ tion. This is not limited to arithmetic substitutions of the
form $((...)), but also includes arithmetical expressions evalu-
- ated in any other way, including by the let builtin, by ((...))
- statements, and even by the return builtin and by array sub-
- scripts. Therefore, care must be taken not to use syntactical
- constructs that perform arithmetic evaluation after evaluating
+ ated in any other way, including by the let builtin, by ((...))
+ statements, and even by the return builtin and by array sub-
+ scripts. Therefore, care must be taken not to use syntactical
+ constructs that perform arithmetic evaluation after evaluating
what is to be the result of the function. For example:
# WRONG
@@ -68,9 +69,9 @@ functions +M [ -m ] mathfn ...
This will print `0' because of the return.
Commenting the return out would lead to a different problem: the
- ((...)) statement would become the last statement in the func-
- tion, so the return status ($?) of the function would be
- non-zero (indicating failure) whenever the arithmetic result of
+ ((...)) statement would become the last statement in the func-
+ tion, so the return status ($?) of the function would be
+ non-zero (indicating failure) whenever the arithmetic result of
the function would happen to be zero (numerically):
# WRONG
@@ -90,12 +91,12 @@ functions +M [ -m ] mathfn ...
functions -M cube 1 1 zmath_cube
print $(( cube(3) ))
- If the additional option -s is given to functions -M, the argu-
- ment to the function is a single string: anything between the
- opening and matching closing parenthesis is passed to the func-
- tion as a single argument, even if it includes commas or white
- space. The minimum and maximum argument specifiers must there-
- fore be 1 if given. An empty argument list is passed as a
+ If the additional option -s is given to functions -M, the argu-
+ ment to the function is a single string: anything between the
+ opening and matching closing parenthesis is passed to the func-
+ tion as a single argument, even if it includes commas or white
+ space. The minimum and maximum argument specifiers must there-
+ fore be 1 if given. An empty argument list is passed as a
zero-length string. Thus, the following string function takes a
single argument, including the commas, and prints 11:
@@ -105,11 +106,11 @@ functions +M [ -m ] mathfn ...
functions -M with no arguments lists all such user-defined func-
tions in the same form as a definition. With the additional op-
- tion -m and a list of arguments, all functions whose mathfn
+ tion -m and a list of arguments, all functions whose mathfn
matches one of the pattern arguments are listed.
function +M removes the list of mathematical functions; with the
- additional option -m the arguments are treated as patterns and
- all functions whose mathfn matches the pattern are removed.
- Note that the shell function implementing the behaviour is not
+ additional option -m the arguments are treated as patterns and
+ all functions whose mathfn matches the pattern are removed.
+ Note that the shell function implementing the behaviour is not
removed (regardless of whether its name coincides with mathfn).