From: estes AT smarts DOT com (Ken Estes) Subject: Env bug Report 26 Jan 1997 15:44:04 -0800 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <199701262234.RAA20688.cygnus.gnu-win32@just.smarts.com> Original-To: gnu-win32 AT cygnus DOT com In-reply-to: <199701241849.MAA14251@natashya.eden.com> (aubrey@eden.com) Original-Sender: owner-gnu-win32 AT cygnus DOT com There are some subtle interactions with Bash and the NT environment. NT requires that environmental variables be alphabetized and under SOME circumstances bash does not do the required alphabetization. Our programs behave very differently when we replace export SM_HOME=j:/src/estes ; \ j:/smarts/sysapi/winnt-i386/runcmd.exe with SM_HOME=j:/src/estes \ j:/smarts/sysapi/winnt-i386/runcmd.exe We invoke a wrapper program (runcmd) which modifies the environment using NT primitives (getenv, putenv to change PATH and not SM_HOME) then invokes other programs. When the environment is not in alphabetical order you end up with two version of the variable in the environment. The variable that a child process will see will depend on the language it is written in! You will see one of these version in C (getenv of PATH will show what you put in with putenv) but perl will show you the original version of the variable (before rumcd inherited it! This is possible since this older version was never removed from the environment an perl uses different primitives to load the ENV hash array). Ironically it is the EXPORT version does not work correctly. Use GetEnvironmentStrings() to examine the environment for alphabetization, and to look for duplicate variables. This problem occurs with build 17.1. I will be happy to debug it further if someone can point me to where the env magic takes place. I know that things are usually alphabetized so I think the cygwin dll already has the code for this. Also there is some other magic going on with PATH (et al.) and slashes changing from forward to NT style when you export. I would like to document this since I do not like to rely on magic that I do not understand. Ken Estes estes AT smarts DOT com - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".