相关疑难解决方法(0)

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

在玩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等)?

bash shell sh

9
推荐指数
1
解决办法
5293
查看次数

标签 统计

bash ×1

sh ×1

shell ×1