Answers:
中的函数bash
本质上称为复合命令(或代码块)。来自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.
没有给出任何原因,只是语法。
由于给定的单行函数中的列表没有以换行符或a终止;
,所以会bash
抱怨。