Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 May 2007 13:21:50 -0500 (CDT)
From:      "Sean C. Farley" <sean-freebsd@farley.org>
To:        Andrey Chernov <ache@freebsd.org>
Cc:        Daniel Eischen <deischen@freebsd.org>, arch@freebsd.org
Subject:   Re: HEADS DOWN
Message-ID:  <20070504085905.J39482@thor.farley.org>
In-Reply-To: <20070503160351.GA15008@nagual.pp.ru>
References:  <20070501083009.GA4627@nagual.pp.ru> <20070501160645.GA9333@nagual.pp.ru> <20070501135439.B36275@thor.farley.org> <20070502.102822.-957833022.imp@bsdimp.com> <Pine.GSO.4.64.0705021332020.8590@sea.ntplx.net> <20070502183100.P1317@baba.farley.org> <Pine.GSO.4.64.0705022034180.8590@sea.ntplx.net> <20070502230413.Y30614@thor.farley.org> <20070503160351.GA15008@nagual.pp.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 3 May 2007, Andrey Chernov wrote:

> On Wed, May 02, 2007 at 11:08:18PM -0500, Sean C. Farley wrote:
>>  On Wed, 2 May 2007, Daniel Eischen wrote:
>>
>>> On Wed, 2 May 2007, Sean C. Farley wrote:
>>
>>  <snip>
>>
>>>> 2. getenv() sets errno to EINVAL and returns NULL if given a bad
>>>>    name to find.  setenv() and unsetenv() perform the same check on
>>>>    the name; should not getenv() do the same?  The check is easy to
>>>>    remove.
>>>
>>> I don't think getenv() should set errno.  The fact that it
>>> returns NULL is sufficient and POSIX doesn't define any errors
>>> for it.
>>
>>  Fixed for errno.  Also, no value is appropriate for errno when the
>>  name does not exist.  How about the feature that getenv() returns a
>>  NULL for a bad name instead of allowing a core dump?  Is that
>>  acceptable?
>
> Speaking about POSIXed error checking in *env() you can look at my
> backed out implemetation (via cvs diff), you may find it useful for
> you.

I believe I check all that you did in your changes.  Mine looks a little
different since some checks were combined for speed (i.e.,
__strleneq()).

The only other question I have is about leading whitespace in the name
passed to *env():
1. Should it be removed up to the first non-whitespace character?
2. Treated as part of the variable name.  Is this allowed by the
    specification?
3. Return errno = EINVAL.  getenv() would just return NULL.

I am leaning towards #2 since it may be desired by a developer.  If
"FOO BAR" is valid, why not " FOOBAR"?  I see that /usr/bin/env
currently allows it.

If #2 is good, then I think my code is functionally complete.  This is
of course not counting any hiding bugs.  :)

Sean
-- 
sean-freebsd@farley.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070504085905.J39482>