功能名称在bash的SH有效,但不 [英] Function name valid in bash but not in sh

查看:89
本文介绍了功能名称在bash的SH有效,但不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

而玩弄的bash和sh,我发现下面是有效的在bash:

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

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

,但不是在SH

but not in sh:

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

为什么会变成这样的区别在那里?请问上面定义的函数违反公约的一些(POSIX等),导致这个错误?

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

推荐答案

这只是小点,你不能使用shell函数名点。或任何变量名,为这一问题。

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

我将您链接到这个问题:<一href=\"http://stackoverflow.com/questions/2821043/allowed-characters-in-linux-environment-variable-names\">Allowed在Linux环境变量名中的字符

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

这篇关于功能名称在bash的SH有效,但不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆