Fonctions en bash
sont essentiellement des commandes composées (ou des blocs de code). A partir de man bash
:
Compound Commands
A compound command is one of the following:
...
{ list; }
list is simply executed in the current shell environment. list
must be terminated with a newline or semicolon. This is known
as a group command.
...
Shell Function Definitions
A shell function is an object that is called like a simple command and
executes a compound command with a new set of positional parameters.
... [C]ommand is usually a list of commands between { and }, but
may be any command listed under Compound Commands above.
Il n'y a pas de raison, c'est juste la syntaxe.
Étant donné que la liste de la fonction d'une ligne donnée n'est pas terminée par un saut de ligne ou un ;
, bash
se plaint.