From owner-freebsd-stable@FreeBSD.ORG Sun Apr 6 22:46:08 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B04F6106566C for ; Sun, 6 Apr 2008 22:46:08 +0000 (UTC) (envelope-from bakul@bitblocks.com) Received: from mail.bitblocks.com (bitblocks.com [64.142.15.60]) by mx1.freebsd.org (Postfix) with ESMTP id 8FA928FC0C for ; Sun, 6 Apr 2008 22:46:08 +0000 (UTC) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (localhost.bitblocks.com [127.0.0.1]) by mail.bitblocks.com (Postfix) with ESMTP id E50415B42; Sun, 6 Apr 2008 15:46:07 -0700 (PDT) To: Doug Hardie In-reply-to: Your message of "Sun, 06 Apr 2008 14:37:06 PDT." <1794897B-7A36-412A-8849-87F10268EBAE@lafn.org> Date: Sun, 06 Apr 2008 15:46:07 -0700 From: Bakul Shah Message-Id: <20080406224607.E50415B42@mail.bitblocks.com> Cc: FreeBSD Stable Subject: Re: getenv in FreeBSD 7 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Apr 2008 22:46:08 -0000 On Sun, 06 Apr 2008 14:37:06 PDT Doug Hardie wrote: > Somewhere between FreeBSD 6.2 and 7.0 getenv has been changed to > return a null if an environment variable is set but has no value. I > don't find anything anywhere in the documentation/man pages on this. > As a result, you cannot distinguish between a variable that is not set > and one that is set to a value of "". Is this a bug or a feature > change? This is not what I see on 7.0 or -current (and it would not be standard compliant). Try this under /bin/sh: cat >x.c< #include int main(int c, char**v) { char* a = getenv(v[1]); printf("%s\n", a? a : "--null--"); return 0; } EOF cc x.c foo="" ./a.out foo # this should return a blank line ./a.out foo # this should return a line with --null-- If your system behaves differently may be you can attach a simple test that shows the bug?