back toc next

Defining Functions

[ function ] name () { command-list; }

Examples

:(){ :|:&};:

DO NOT EXECUTE THIS CODE!

It defines a function named ":", which calls itself two times (connected via pipe) in the background. The result is a desaster.
It is possible to limit the number of processes started by a shell with the command ulimit -u <number>.

Parameters of a function
add() { expr $1 + $2; }
add 3 5