跨操作系统环境变量的有效字符
在尝试根据系统属性和环境变量为不同的应用程序创建可靠的应用程序配置策略时,我问自己是否存在适用于所有操作系统的已知字符和特殊字符。
例如,在我的 Mac OS X 上,点不能在环境变量中轻松使用,因为在我的 .profile
文件中不可能按照我设置其他环境变量的方式设置它们:
# configuration for myapp
grails.myapp.config=/some/directory/and/file.groovy;
export grails.myapp.config
据我所知,通常环境变量有包含大写字母和下划线的键。是否存在可以在所有常见操作系统中使用的所有字符的已知子集?
While trying to create a reliable application configuration strategy for different applications based on system properties and environment variables I asked myself whether there are known characters and special chars that work across all operating systems.
For example on my Mac OS X dots cannot be easily used in environment variables because setting them the way I set other environment variables was not possible inside my .profile
file:
# configuration for myapp
grails.myapp.config=/some/directory/and/file.groovy;
export grails.myapp.config
As far as I know usually environment variables have a key with uppercase letters and the underscore in it. Is there a known subset of all characters that I can use across all common operating systems?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我查看了 Open Group/POSIX 标准网站以了解他们的说法。他们的 XCU 规范要求支持大写字母、数字< /em> 和下划线(所以你所期望的加上数字 0-9)。
至少是一个可以参考的标准。
I looked at the Open Group/POSIX standards site to see what they say. Their XCU specification calls for support of uppercase letters, digits, and underscores (so what you anticipated plus the digits 0-9).
At least it's a referenceable standard.
Paranoia 101:仅使用 ASCII 字母字符和下划线。一般来说,大写和小写字母都是合法的,但惯例规定使用大写字母。
Paranoia 101: use ASCII letter characters and underscores only. Generally upper and lower case letters are legal, but convention dictates using upper case letters.