Function name valid in bash but not in sh [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-12-01 00:16:50

问题


While playing around with bash and sh, I found out that the following is valid in bash:

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

but not in sh:

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

Why would this difference be there? Does the function defined above violate some convention (POSIX etc.) that causes this error?


回答1:


It's just the dots, you can't use dots in shell function names. Or any variable name, for that matter.

I'll link you to this question: Allowed characters in linux environment variable names



来源:https://stackoverflow.com/questions/20771743/function-name-valid-in-bash-but-not-in-sh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!