delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/10/14/16:27:32

From: casley AT VSISInc DOT COM (Ross Casley)
Subject: Re: Gnu-win32 beta release 18: make bug - 'export' has no effect
14 Oct 1997 16:27:32 -0700 :
Message-ID: <199710141925.MAA02970.cygnus.gnu-win32@aussie.vsisinc.com>
To: gnu-win32 AT cygnus DOT com
Cc: "'annakam AT lmc DOT com'" <annakam AT lmc DOT com>, casley AT VSISInc DOT COM

annakam AT lmc DOT com noticed in the last week that the export command in make
doesn't do what it should.  I had the same problem.  

Here's the deal.

make expects to change a process's environment by assigning to the global
variable environ.  Specifically, it constructs a new environment in envp
and starts off a new program using this code:

	environ = envp;
	execvp(argv[0], argv);

Unfortunately, that doesn't work in gnu-win32.  Assigning to environ does
not change the environment seen after an execvp() (or the environment used
by getenv() and putenv()).

One obvious fix is to replace execvp() with execve() so as to set the
environment explicitly.  But a nice thing about execvp() is that it
searches the path itself to find argv[0].  With execve() you have to
search the path yourself.

Can anybody point me to either

	- A good way to set the current environment to be envp, or
	- A good way to search for a program on PATH?

[Note that it is not really correct just to use putenv() to change the
 current environmant, since an 'unexport' command may require you to
 remove variables from the environment.]

Many thanks in advance,

-Ross Casley
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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