git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add ability to specify environment extension to run_command

From
Junio C Hamano <junkio@cox.net>
Date
May 22, 2007, 06:33 UTC
Message-ID
<7v646l9xkn.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070522060302.GH5412@admingilde.org>
Martin Waitz <tali@admingilde.org> writes:
Show 8 quoted lines
> On Mon, May 21, 2007 at 04:02:42PM -0700, Junio C Hamano wrote:
>> I had a feeling that some callers needed to be able to unsetenv
>> some.  How would this patch help them, or are they outside of
>> the scope?
>
> At first I had the same objection but the putenv documentation
> told me that at least in glibc you can unsetenv by providing
> the variable name without a "=".

I recall SysV putenv() does not remove "ENVNAME" without '=', and http://www.opengroup.org/onlinepubs/000095399/functions/putenv.html seems to say that as well.

> But perhaps we should check for other systems?
Probably.

At least we have setenv/unsetenv calls already (with emulation where they aren't available), we could do something like this:

	struct child_process {
        	...
                const struct {
                        const char *name;
                        const char *value; /* NULL to unsetenv */
                } *env;
		...
	};
and in start_command():
	if (cmd->env) {
		int i;
                for (i = 0; cmd->env[i].name; i++) {
			if (cmd->env[i].value)
				setenv(cmd->env[i].name, cmd->env[i].value, 1);
			else
				unsetenv(cmd->env[i].name);
                }
        }
Previous: Martin WaitzNext: Shawn O. Pearce
Message 10 of 20 in “allow commands to be executed in submodules”
  1. allow commands to be executed in submodulesMartin Waitz, May 20, 2007
  2. Alex RiesenMay 20, 2007
  3. Junio C HamanoMay 20, 2007
  4. Martin WaitzMay 20, 2007
  5. Alex RiesenMay 20, 2007
  6. Martin WaitzMay 20, 2007
  7. Add ability to specify environment extension to run_commandAlex Riesen, May 21, 2007
  8. Junio C HamanoMay 21, 2007
  9. Martin WaitzMay 22, 2007
  10. Junio C HamanoMay 22, 2007
  11. Shawn O. PearceMay 22, 2007
  12. Sven VerdoolaegeMay 22, 2007
  13. Alex RiesenMay 22, 2007
  14. Alex RiesenMay 22, 2007
  15. Add run_command_v_opt_cd: chdir into a directory before execAlex Riesen, May 22, 2007
  16. Add ability to specify environment extension to run_commandAlex Riesen, May 22, 2007
  17. Allow environment variables to be unset in the processes started by run_commandAlex Riesen, May 22, 2007
  18. Junio C HamanoMay 22, 2007
  19. Alex RiesenMay 22, 2007
  20. Allow environment variables to be unset in the processes started by run_commandAlex Riesen, May 23, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.