I looked over various documentation on getenv()
, all they describe is how to use it and what it does i.e environment variable whose name is specified as argument.
But, I am trying to find the complete list or at开发者_运维百科least as many as possible which can be used with getenv()
I know few like,
MANPATH
HOSTNAME
PATH
INFOPATH
PKG_CONFIG_PATH
USER
Can somebody help me extend this list?
getenv queries your environment for any variable name. In Unix you can set any variable in the shell so there is no limit to what can be used (In OSX I think it is any Unicode string with no whitespace) Thus there is no complete list.
To see what is in your environment type env
in a Terminal window.
Or as per Unix standard
The value of an environment variable is a string of characters. For a C-language program, an array of strings called the environment is made available when a process begins. The array is pointed to by the external variable environ, which is defined as:
extern char **environ;
There is no complete list, because any user or any program can define their own environment variables with their own meanings. You might ask for the complete list of variables that a given program understands -- in that case often the man page for the program will list them.
精彩评论