Valid characters for environment variables across operating systems
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 variab开发者_如何学编程les 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?
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: use ASCII letter characters and underscores only. Generally upper and lower case letters are legal, but convention dictates using upper case letters.
精彩评论