Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: putenv()/environ bug
- X-seq: zsh-workers 23703
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: putenv()/environ bug
- Date: Wed, 25 Jul 2007 21:53:21 +0100
- Cc: "Sean C. Farley" <scf@xxxxxxxxxxx>
- In-reply-to: <20070725093254.T20275@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20070725093254.T20275@xxxxxxxxxxxxxxx>
On Wed, 25 Jul 2007 10:09:22 -0500 (CDT)
"Sean C. Farley" <scf@xxxxxxxxxxx> wrote:
> As noticed here[1] following a change[2] in FreeBSD's *env() functions,
> zsh is mixing *env() (putenv() in this case) functions with direct
> access to the environ variable's contents against the IEEE Std 1003.1
> specification.
>
> BTW, is there a particular reason the standard *env() functions cannot
> be used for all operations to environ if found?
There's a long history of fiddling with these for problems on various
systems, so I'm a little unwilling to change it without some guidance.
For example,
/*
* Under Cygwin we must use putenv() to maintain consistency.
* Unfortunately, current version (1.1.2) copies argument and may
* silently reuse existing environment string. This tries to
* check for both cases
*/
This is a little confusing since the code in question (addenv in
params.c) doesn't actually use putenv().
Given we manipulate environ quite a lot anyway, is there any harm in
using only the zsh versions of zgetenv() and zputenv()? There's a
getenv() instead of a zgetenv() in init.c: I think that was just a typo
by me.
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.76
diff -u -r1.76 init.c
--- Src/init.c 6 Jul 2007 21:52:39 -0000 1.76
+++ Src/init.c 25 Jul 2007 20:53:06 -0000
@@ -832,7 +832,7 @@
if (emulation == EMULATE_ZSH)
ptr = home;
else
- ptr = getenv("HOME");
+ ptr = zgetenv("HOME");
if (ptr && ispwd(ptr))
pwd = ztrdup(ptr);
else if ((ptr = zgetenv("PWD")) && (strlen(ptr) < PATH_MAX) &&
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author