Martin Maechler
1999-Sep-29 13:57 UTC
getenv() can't differentiate "defined but empty" and "undefined"
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 ? Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO D10 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian D Ripley
1999-Sep-29 14:52 UTC
getenv() can't differentiate "defined but empty" and "undefined"
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 ?I think it should really be NULL if undefined: attributes which may or may not be there are a nuisance. The only problem I can see is in system.gnw.r, whihc doe use nchar on getenv. Small point: when do you want to change this? It is platform-specific code. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Maybe Matching Threads
- Sys.getenv(): Error in substring(x, m + 1L) : invalid multibyte string at '<ff>' if an environment variable contains \xFF
- [LLVMdev] Usage of getenv() inside LLVM and thread safety
- [LLVMdev] Usage of getenv() inside LLVM and thread safety
- Sys.getenv at startup is not working properly
- Sys.getenv