delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/04/29/10:11:05

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
X-Lotus-FromDomain: ISIS ASSOCIATES
From: "Michael K Collison" <Michael_K_Collison AT iassoc DOT ultranet DOT com>
To: cygwin AT sourceware DOT cygnus DOT com
Message-ID: <85256762.004D84D8.00@osiris.iassoc.ultranet.com>
Date: Thu, 29 Apr 1999 10:07:34 -0400
Subject: Re: Problem with getenv
Mime-Version: 1.0



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 AT xraylith DOT wisc DOT 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 AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019