Mail Archives: cygwin/2006/02/09/10:45:34
On 8-Feb-2006 16:41, Christopher Faylor wrote:
> On Tue, Feb 07, 2006 at 01:25:12PM -0600, Brian Ford wrote:
>
>> On Tue, 7 Feb 2006, Christopher Faylor wrote:
>>
>>
>>> I believe that Brian Ford is looking into modifying the new CW_SETUP_WINENV
>>> code to perform the proper conversion of POSIX style to Windows style.
>>>
>> We're still debating aproaches for solving our problem, so it is possible
>> I won't get to it. If someone else wants to try, feel free.
>>
>
> Well, that's disappointing. I'm not aware of any debates. I thought
> just this once we could rely on someone else fixing a problem.
>
> I guess I'll look into this when I get a chance.
>
>
Well, the below code works for cygstart, and does the right thing for
the variables Cygwin converts from POSIX <-> Win32.
Feel free to adapt this to CW_SETUP_WINENV. (Although it might be more
elegant to use conv_envvars[] from environ.cc there.)
If I hear no objections, I'm going to submit this as a path for
cygutils, and ask Chuck to release it. If and when this gets fixed in
CW_SETUP_WINENV, and released, I'll change it to use that instead.
– Michael
/* Copy cygwin environment variables to the Windows environment if
they're not
* already there. */
static void setup_win_environ(void)
{
char **envp = environ;
char *var, *val;
char curval[2];
char *winpathlist;
char winpath[MAX_PATH+1];
while (envp && *envp) {
var = strdup(*envp++);
val = strchr(var, '=');
*val++ = '\0';
if (GetEnvironmentVariable(var, curval, 2) == 0
&& GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
/* Convert POSIX to Win32 where necessary */
if (!strcmp(var, "PATH") ||
!strcmp(var, "LD_LIBRARY_PATH")) {
winpathlist = (char *)
malloc(cygwin_posix_to_win32_path_list_buf_size(val));
if (winpathlist) {
cygwin_posix_to_win32_path_list(val, winpathlist);
SetEnvironmentVariable(var, winpathlist);
free(winpathlist);
}
} else if (!strcmp(var, "HOME") ||
!strcmp(var, "TMPDIR") ||
!strcmp(var, "TMP") ||
!strcmp(var, "TEMP")) {
cygwin_conv_to_win32_path(val, winpath);
SetEnvironmentVariable(var, winpath);
} else {
SetEnvironmentVariable(var, val);
}
}
free(var);
}
}
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -