Linux 环境变量名称中允许的字符 [英] Allowed characters in Linux environment variable names

查看:38
本文介绍了Linux 环境变量名称中允许的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Linux 环境变量名称中允许使用哪些字符?我对手册页和网络的粗略搜索只提供了有关如何使用变量的信息,但没有提供允许使用哪些名称的信息.

What characters are allowed in Linux environment variable names? My cursory search of man pages and the web did only produce information about how to work with variables, but not which names are allowed.

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

I have a Java program that requires an defined environment variable containing a dot, like com.example.fancyproperty. With Windows I can set that variable, but I had no luck setting it in linux (tried in SuSE and Ubuntu). Is that variable name even allowed?

推荐答案

来自 The公开组:

这些字符串的形式为名称=值;名称不得包含字符 '='. 值可跨系统移植符合IEEE Std 1003.1-2001,该值应为由字符组成可移植字符集(NUL 除外并如下所示).

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 之外的任何字符,但是:

So names may contain any character except = and NUL, but:

Shell 中的实用程序使用的环境变量名称和IEEE Std 公用事业量1003.1-2001 仅由大写字母、数字和_"组成(下划线) 来自字符在可移植字符集和不要以数字开头.其他字符可能被允许执行;申请须容忍这些名字的存在.

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 可能不支持除字母、数字和下划线之外的任何内容.

So while the names may be valid, your shell might not support anything besides letters, numbers, and underscores.

这篇关于Linux 环境变量名称中允许的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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