它不是bash中的约定(或者更常见的是POSIX-family shell).
至于"为什么",那是因为做错的各种方式都具有作为命令的有效含义.如果你做了NUM2 = 4
一个作业,那么你就不能=
在没有引用它的情况下作为文字参数传递.因此,任何此类更改都是向后兼容的,而不是放在未定义的空间中(POSIX sh标准的扩展需要生存以避免违反该标准).
NUM2= 4 # runs "4" as a command, with the environment variable NUM2 set to an empty string NUM2 =4 # runs "NUM2" as a command, with "=4" as its argument NUM2 = 4 # runs "NUM2" as a command, with "=" as its first argument, and "4" as another