• # man sh

    Posté par . En réponse au message fonction en bourne shell. Évalué à 2.

    http://unixhelp.ed.ac.uk/CGI/man-cgi?sh(...)

    FUNCTIONS
    A shell function, defined as described above under SHELL GRAMMAR,
    stores a series of commands for later execution. When the name of a
    shell function is used as a simple command name, the list of commands
    associated with that function name is executed. Functions are executed
    in the context of the current shell; no new process is created to
    interpret them (contrast this with the execution of a shell script).
    When a function is executed, the arguments to the function become the
    positional parameters during its execution. The special parameter # is
    updated to reflect the change. Positional parameter 0 is unchanged.
    The FUNCNAME variable is set to the name of the function while the
    function is executing. All other aspects of the shell execution envi-
    ronment are identical between a function and its caller with the excep-
    tion that the DEBUG trap (see the description of the trap builtin under
    SHELL BUILTIN COMMANDS below) is not inherited unless the function has
    been given the trace attribute (see the description of the declare
    builtin below).

    Variables local to the function may be declared with the local builtin
    command. Ordinarily, variables and their values are shared between the
    function and its caller.

    If the builtin command return is executed in a function, the function
    completes and execution resumes with the next command after the func-
    tion call. When a function completes, the values of the positional
    parameters and the special parameter # are restored to the values they
    had prior to the function's execution.

    Function names and definitions may be listed with the -f option to the
    declare or typeset builtin commands. The -F option to declare or type-
    set will list the function names only. Functions may be exported so
    that subshells automatically have them defined with the -f option to
    the export builtin.

    Functions may be recursive. No limit is imposed on the number of
    recursive calls.