From: David Michael Date: Sat, 05 Jan 2013 02:15:55 GMT Subject: Re: [BUG/PATCH] setup: Copy an environment variable to avoid overwrites Message-ID: In-Reply-To: <7vsj6gqvhc.fsf@alter.siamese.dyndns.org> Hi, On Fri, Jan 4, 2013 at 8:17 PM, Junio C Hamano wrote: > In fact, > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/getenv.html > > says that only setenv(), unsetenv() and putenv() may invalidate > previous return values. Note that getenv() is not listed as a > function that is allowed to break return values from a previous call > to getenv(). Before I sent the e-mail, I checked that very page to be sure I wasn't entirely insane. Specifically, the second paragraph begins with: > The string pointed to may be overwritten by a subsequent call to getenv(), [...] I read that line as confirmation that this is indeed acceptably standard behavior. Even the getenv man page on my Fedora workstation says: > The string pointed to by the return value of getenv() may be statically allocated, and can be modified by a subsequent call to getenv(), putenv(3), setenv(3), or unsetenv(3). Am I misinterpreting these statements? Thanks. David