This is the mail archive of the cygwin@sourceware.cygnus.com
mailing list for the Cygwin project. See the Cygwin
home page for more information.
Re: Problem with getenv
- To: cygwin@sourceware.cygnus.com
- Subject: Re: Problem with getenv
- From: "Michael K Collison" <Michael_K_Collison@iassoc.ultranet.com>
- Date: Thu, 29 Apr 1999 10:07:34 -0400
Problem fixed (fix described below). Thanks to Mumit.
Mike
---------------------- Forwarded by Michael K Collison/ISIS ASSOCIATES on
04/29/99 10:06 AM ---------------------------
Mumit Khan <khan@xraylith.wisc.edu> on 04/29/99 01:59:06 AM
To: Michael K Collison/ISIS ASSOCIATES
cc:
Subject: Re: Problem with getenv
On Thu, 29 Apr 1999, Michael K Collison wrote:
> #include <process.h>
>
Thanks for the test code. Always helps putting things into perspective.
btw, you should include <stdlib.h>, not <process.h> if you're looking
for POSIX code. system() is ANSI and thus available on any system and
prototyped in stdlib.h.
> main()
> {
> char *path;
> int i;
>
> path = getenv("TEST");
> i = system(path);
> }
>
> I set the environment variable TEST in my case to be 'd:\temp\hello.exe'.
> Where 'hello.exe' was just
> your standard hello world program. I get the same error as before.
>
Ah, there's the problem. The way "system" works, it simply passes the
entire command string to the SHELL to run without any modifications
whatsoever. If you use Cygwin, I recommend you use POSIX pathnames
(or at least c:/foo/bar format).
$ TEST=d:/temp/hello.exe ./testprog
should do the job. As will the POSIX and hence the preferred way:
$ TEST=//d/temp/hello.exe ./testprog
How to fix this in winsup (ie., the cygwin DLL core)? In system routine,
check for the first "word" (which is guaranteed to be a pathname),
change all the '\\' to '/'.
Please feel free to forward this to the mailing list. Others may be
interested, and I won't forward this w/out your explicit permission.
Regards,
Mumit
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com