|
|
Functions can be defined to perform frequently-needed
sequences of commands.
The syntax is:
function name { script }
which assigns name as the name of script.
The script is not evaluated at this point, though it will be parsed and checked for syntax errors.
The assignment can be canceled with:
function name { }
The list of arguments to the function is passed to the function in the variable ``*''.
A function can return a result, which can be used with the `( ) syntax. For example:
function makeday { return $*^'day' }defines a function to append 'day' to each of its arguments. Thus:
A=Sun B=`(makeday $A)sets $B to ```Sunday'''.