Skip to content

Sys.getenv

2 messages · Christian Schulz, Peter Dalgaard

#
I am running R-1.3.0 on Solaris 8:

Under Solaris I do
setenv dendro_us hoffmann

echo $dendro_us gives back:
hoffmann

which is correct.

When in R I do:

Sys.getenv("dendro_us")  I get
dendro_us 
       "" 

which is NOT correct:

Inverse effect (taken from help of Sys.getenv)
Under R:
print(Sys.putenv("R_TEST"="testit", ABC=123))
[1] TRUE TRUE
Sys.getenv("R_TEST")   gives back:
  R_TEST 
"testit" 
which seems correct.

When in Solaris I do:
echo $R_TEST
R_TEST: Undefined variable.

which is NOT correct:

Third type of behaviour:
echo $HOME
/home/woodstock/hoffmann
and
Sys.getenv("HOME")
                      HOME 
"/home/woodstock/hoffmann" 

which are both correct.

QUESTION:
Are there two versions of the environment around? Or what am I missing?
SunOS fluke 5.7 Generic_106541-12 sun4d sparc SUNW,SPARCserver-1000

Thanks for help.

-christian
Dr.sc.math.Christian W. Hoffmann
Mathematics and Statistical Computing
Landscape Modeling and Web Applications
Swiss Federal Research Institute WSL 
Zuercherstrasse 111
CH-8903 Birmensdorf, Switzerland
phone: ++41-1-739 22 77    fax: ++41-1-739 22 15
e-mail: christian.hoffmann_at_wsl.ch__prevent_spamming
www: http://www.wsl.ch/staff/christian.hoffmann/

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Christian Hoffmann <christian.hoffmann at lagonda.wsl.ch> writes:
?? (see below)
It's not quite clear to me exactly what you're doing, but the thing
that usually confuses people about environments is the following:

Environments exist on a per-process basis. A child process inherits a
*copy* of the parent environment. Making changes to an environment
does not affect the environment of any other running process.

E.g. the following is expected:
bar
$ echo $FOO

$ 
but this should work (parallel to setenv but Bourne shell syntax):


$ BAR=foo ; export BAR
$ R --quiet
BAR 
"foo"
??? (that'd make it Solaris 7, no?)