在玩bash和sh时,我发现以下内容在bash中有效:
system.out.println () { printf "$1"; }
Run Code Online (Sandbox Code Playgroud)
但不是sh:
sh: `system.out.println': not a valid identifier
Run Code Online (Sandbox Code Playgroud)
为什么会出现这种差异?上面定义的函数是否违反导致此错误的某些约定(POSIX等)?
Noc*_*tua 11
它只是点,你不能在shell函数名称中使用点.或者任何变量名称.
我将链接到这个问题:linux环境变量名中的允许字符