函数名在bash中有效但在sh中没有

时间:2013-12-25 10:30:20

标签: bash shell sh

在玩bash和sh时,我发现以下内容在bash中有效:

system.out.println () { printf "$1"; }

但不是sh:

sh: `system.out.println': not a valid identifier

为什么会出现这种差异?上面定义的函数是否违反导致此错误的某些约定(POSIX等)?

1 个答案:

答案 0 :(得分:11)

只是圆点,你不能在shell函数名中使用点。或者任何变量名称。

我会将您链接到这个问题:Allowed characters in linux environment variable names