From Martin Maechler <maechler@stat.math.ethz.ch>  Wed Sep 29 16:52:17 1999
From: Martin Maechler <maechler@stat.math.ethz.ch> (Martin Maechler)
Date: Wed, 29 Sep 1999 17:52:17 +0200
Subject: getenv() can't differentiate  "defined but empty" and "undefined"
In-Reply-To: <Pine.GSO.4.05.9909291546210.13114-100000@auk.stats> (message
 from Prof Brian D Ripley on Wed, 29 Sep 1999 15:52:35 +0100 (BST))
References: <Pine.GSO.4.05.9909291546210.13114-100000@auk.stats>
Message-ID: <199909291552.RAA15706@sophie.ethz.ch>

>>>>> On Wed, 29 Sep 1999 Prof Brian D Ripley <ripley@stats.ox.ac.uk> said:

    BDR> On Wed, 29 Sep 1999, Martin Maechler wrote:
    >> getenv(<varname>) currently returns "" if the <varname> is
    >> undefined.
    >> 
    >> However, if <varname> is defined but empty, getenv(<varname>) still
    >> only returns "".
    >> 
    >> I think this is quite unfortunate but consistent with the prototype.
    >> 
    >> ---
    >> I'd propose to change the current behavior.  Something which should
    >> be pretty back compatible would for the first case (undefined
    >> environment variable) to return "" with an attribute "defined" set
    >> to FALSE i.e.  return(structure("", defined = FALSE))
    >> 
    >> Does anyone see a problem with this approach ?

    BDR> I think it should really be NULL if undefined: attributes which
    BDR> may or may not be there are a nuisance. 

that was my first thought, as well, however ...

    BDR> The only problem I can
    BDR> see is in system.gnw.r, whihc doe use nchar on getenv.

and all the user code from S and R which assumes that getenv() returns 
a character() as it is documented !

    BDR> Small point: when do you want to change this? It is
    BDR> platform-specific code.

 (why does this need to be specific? 
   -- yes I was too lazy to study the code ..)

Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


getenv() can't differentiate "defined but empty" and "undefined"
Martin Maechler