Re: [BUG/PATCH] setup: Copy an environment variable to avoid overwrites
- From
David Michael <fedora.dm0@gmail.com>
- Date
- Jan 5, 2013, 02:15 UTC
- Message-ID
- <CAEvUa7mbs7rfGdfzbGb9p889K7GUbXFg9TUcFWFYKt8+8AKCiQ@mail.gmail.com>
- In-Reply-To
- <7vsj6gqvhc.fsf@alter.siamese.dyndns.org>
Hi,
On Fri, Jan 4, 2013 at 8:17 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
> 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