This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
RE: 1.3.4: error in inheriting new PATH environment form WIN32 executable to CYGWIN executable
- To: Heiko_Elger at arburg dot com, "'Gerrit P. Haase'" <cygwin at cygwin dot com>
- Subject: RE: 1.3.4: error in inheriting new PATH environment form WIN32 executable to CYGWIN executable
- From: Heribert Dahms <heribert_dahms at icon-scm dot com>
- Date: Wed, 7 Nov 2001 23:06:39 +0100
Hi Heiko,
I've never used such a very long string constant on a single source line.
To check that it's not clipped by the (borland) compiler insert at top of
main:
printf("intended PATH: %s\n", long_path);
Bye, Heribert (heribert_dahms@icon-scm.com)
> -----Original Message-----
> From: Gerrit P. Haase [SMTP:gerrit@familiehaase.de]
> Sent: Wednesday, November 07, 2001 16:50
> To: Heiko_Elger@arburg.com
> Cc: cygwin@cygwin.com
> Subject: Re: 1.3.4: error in inheriting new PATH environment form
> WIN32 executable to CYGWIN executable
>
> Hallo Heiko,
>
> 2001-11-07 16:10:14, du schriebst:
>
> > If a MS WIN 32 program changes his environment PATH variable to a very
> long
> > value (over 270 characters) and than calling a CYGWIN program per
> system() call
> > the path inside the CYGWIN program is reset to NULL! If it calls a MS
> WIN 32
> > program all works fine.
>
> > We have this problem with clearmake in exporting a very long path and
> the shell
> > is the CYGWIN sh.exe.
>
> > I tried to reproduce it within a very small test.
> > I wrote two small programs (belwo you wil find the sourcecode):
> > changeenv.c --> MS WIN 32 program which change his PATH environment
> and calls
> > per system() the program "printpath"
> > printpath.c --> prints the PATH environment to stdout
>
> > changeenv.exe is compiled with Microsoft Visual Studio.
> > printpath.exe is compiled with MS Visual Studio and cygwin gcc
>
> > I hope anyone can reproduce this error and give me a hint to resolve may
> > problem.
>
> Yes, I used borland cc, there it is also not ok. Why not use gcc?
>
> At first I have modified the sources a little:
>
> > ----------------------- start changeenv.c --------------------
> #include <stdio.h>
> #include <stdlib.h>
>
> #define CYGWIN_SHELL "c:/cygwin/bin/sh"
> #define CYGWIN_PRINTPATH "c:/cygwin/home/Gerrit/script/printpath_gcc"
> #define WIN32_PRINTPATH "c:/cygwin/home/Gerrit/script/printpath_bcc"
>
> char long_path[] =
> "PATH=/usr/bin:/1234567890123456789012345678901234567890123456789012345678
> 90123456789012345678901234567890123456789012345678901234567890123456789012
> 34567890123456789012345678901234567890123456789012345678901234567890123456
> 78901234567890123456789012345678901234567890/12345678901234567890123456789
> 01234567890123456789012345678901234567890123456789012345678901234567890123
> 45678901234567890123456789012345678901234567890123456789012345678901234567
> 8901234567890123456789012345678901234567890123456789012345678901234567890"
> ;
>
> int main (int argc, char ** argv, char **env)
> {
> int rc=0;
> char * env_path ;
>
> if (putenv(long_path) == -1)
> perror("putenv()");
>
> env_path = getenv("PATH");
> printf("NEW PATH=\n%s\n", env_path == NULL ? "" : env_path);
> if (system( CYGWIN_SHELL " -ic \"echo system CYGWIN SHELL PATH=\"") !=
> 0)
> perror("system()");
> if (system( CYGWIN_SHELL " -ic \"echo $PATH\"") != 0)
> perror("system()");
> printf("system CYGWIN printpath: "); fflush( stdout );
> if (system( CYGWIN_PRINTPATH ) != 0)
> perror("system()");
> printf("system WIN32 printpath: "); fflush( stdout );
> if (system( WIN32_PRINTPATH ) != 0)
> perror("system()");
>
> return rc;
> }
> > ----------------------- end changeenv.c --------------------
>
> > ----------------------- start printpath.c --------------------
> #include <stdio.h>
> #include <stdlib.h>
>
> int main (int argc, char ** argv, char **env)
> {
> int rc=0;
> char * env_path ;
>
> env_path = getenv("PATH");
> printf("PATH=\n%s\n", env_path == NULL ? "" : env_path);
>
> return rc;
> }
> > }----------------------- end printpath.c --------------------
>
[Heribert] [test output snipped]
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/