linux合法变量名,Linux环境变量名中允许的字符

Linux环境变量的名称可以包含除等号('=')和NUL字符外的任何字符,但具体实现可能仅支持字母、数字和下划线。Java程序需要的包含点号的变量名在理论上是有效的,但某些Shell可能不支持。解决方案是检查所用Shell的文档以确认其对环境变量名称的限制。
摘要由CSDN通过智能技术生成

Linux环境变量名称中允许哪些字符?我粗略地搜索手册页和网页只会产生有关如何使用变量的信息,但不会产生允许使用哪些名称的信息.

我有一个Java程序,它需要一个包含点的已定义环境变量,如com.example.fancyproperty.使用Windows我可以设置该变量,但我没有运气在linux中设置它(在SuSE和Ubuntu中尝试过).这个变量名是否允许?

解决方法:

These strings have the form

name=value; names shall not contain

the character ‘=’. For values to be

portable across systems conforming to

IEEE Std 1003.1-2001, the value shall

be composed of characters from the

portable character set (except NUL

and as indicated below).

所以名称可以包含除=和NUL之外的任何字符,但是:

Environment variable names used by the utilities in the Shell and

Utilities volume of IEEE Std

1003.1-2001 consist solely of uppercase letters, digits, and the ‘_’

(underscore) from the characters

defined in Portable Character Set and

do not begin with a digit. Other

characters may be permitted by an

implementation; applications shall

tolerate the presence of such names.

因此,尽管名称可能有效,但您的shell可能不支持除字母,数字和下划线之外的任何内容.

标签:linux,syntax,environment-variables

来源: https://codeday.me/bug/20190915/1805606.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值