...
The getenv()
function searches an environment list for a string that matches a specified name, and returns a pointer to a string associated with the matched list member. Depending on the implementation, multiple environment variables with the same name may be allowed and can cause unexpected results if a program cannot consistently choose the same value. The GNU glibc library addresses this issue in getenv()
and setenv()
by always using the first variable it encounters and ignoring the rest. Other implementations are following suit, although it is unwise to rely on this.
Running a program with duplicate environment variables is a fairly simple task, as the execve()
function has the signature:
Code Block |
---|
int execve(const char *filename, char *const argv[], char *const envp[]);
|
and makes no guarantees with regard to duplicate variables in its envp
argument.
Wiki Markup |
---|
One common difference between implementations is whether or not environment variables are case sensitive. While UNIX-like implementations are generally case sensitive, environment variables are "not case sensitive in Windows 98/Me and Windows NT/2000/XP" \[[MSDN|AA. C References#MSDN]\]. |
...