function reserved word is used to define shell functions.
Shell functions are read in and stored internally. Alias names are
resolved when the function is read. Functions are executed like
commands with the arguments passed as positional parameters.
Functions execute in the same process as the caller and share all files
and the present working directory with the caller. A trap on
EXIT set inside a function is executed after the function
completes in the environment of the caller.
return builtin is used to return from function calls.
Function identifiers can be listed with the
Functions can be undefined with the
The following functions, if defined, have special meaning to the shell:
PERIODis set, this function is executed every
PERIODseconds, just before a prompt.
SIGxxx, where xxx is a signal name as specified for the
killbuiltin (see section Shell Builtin Commands). In addition,
TRAPZERRis executed whenever a command has a non-zero exit status,
TRAPDEBUGis executed after each command, and
TRAPEXITis executed when the shell exits, or when the current function exits if defined inside a function. If a function of this form is defined and null, the shell and processes spawned by it will ignore
Go to the first, previous, next, last section, table of contents.