- 论坛徽章:
- 1
|
本帖最后由 howandsen 于 2018-03-30 19:30 编辑
例一:
分号和换行一样只是众多 control operator 中的一种。
只有命令结尾才需要加 control operator ,变量赋值严格来讲不是命令,而是命令的前置。
所以多个变量赋值之间不应该用分号分割,因为分号和换行的作用是等同的。
man bash 中也明确定义了简单命令的组成——由一系列可选的变量赋值开始。
SHELL GRAMMAR
Simple Commands
A simple command is a sequence of optional variable assignments followed by blank-separated words and redirections, and terminated by a control operator...
例二:
如果变量赋值后面加了命令,则变量成为后面命令的环境变量,并且对当前 shell 无效。
SIMPLE COMMAND EXPANSION
...
If no command name results, the variable assignments affect the current shell environment. Oth‐erwise, the variables are added to the environment of the executed command and do not affect thecurrent shell environment...
|
|