The R Project SVN R

Rev

Rev 61153 | Rev 78972 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/base/man/Sys.setenv.Rd
2
% Part of the R package, http://www.R-project.org
59039 ripley 3
% Copyright 1995-2011 R Core Team
42333 ripley 4
% Distributed under GPL 2 or later
5
 
40393 ripley 6
\name{Sys.setenv}
56186 murdoch 7
\alias{Sys.setenv}
40376 ripley 8
\alias{Sys.unsetenv}
9
\title{Set or Unset Environment Variables}
9925 ripley 10
\usage{
40393 ripley 11
Sys.setenv(\dots)
40376 ripley 12
 
13
Sys.unsetenv(x)
9925 ripley 14
}
15
\arguments{
40387 ripley 16
  \item{\dots}{named arguments with values coercible to a character string.}
40376 ripley 17
  \item{x}{a character vector, or an object coercible to character.}
9925 ripley 18
}
19
\description{
40473 ripley 20
  \code{Sys.setenv} sets environment variables (for other processes
21
  called from within \R or future calls to \code{\link{Sys.getenv}} from
22
  this \R process).
40376 ripley 23
 
40387 ripley 24
  \code{Sys.unsetenv} removes environment variables.
9925 ripley 25
}
26
\value{
40376 ripley 27
  A logical vector, with elements being true if (un)setting the
40403 ripley 28
  corresponding variable succeeded.  (For \code{Sys.unsetenv} this
29
  includes attempting to remove a non-existent variable.)
9925 ripley 30
}
31
\details{
50567 ripley 32
  Non-standard \R names must be quoted in \code{Sys.setenv}: see the
33
  examples.  Most platforms (and POSIX) do not allow names containing
34
  \code{"="}.  Windows does, but the facilities provided by \R may not
54677 ripley 35
  handle these correctly so they should be avoided.  Most platforms
36
  allow setting an environment variable to \code{""}, but Windows does
61153 ripley 37
  not, and there \code{Sys.setenv(FOO = "")} unsets \env{FOO}.
61433 ripley 38
 
45786 ripley 39
  There may be system-specific limits on the maximum length of the values
40
  of individual environment variables or of all environment variables.
41
#ifdef windows
42
  Windows has a limit of 32,767 characters on the environment block, and
43
  \code{cmd.exe} has a limit of 2047 (Windows 2000) or 8192 characters
44
  (XP and later) for each value.
45
#endif
9925 ripley 46
}
49649 ripley 47
% http://support.microsoft.com/kb/830473
48
 
58044 murdoch 49
#ifdef unix
9925 ripley 50
\note{
41571 ripley 51
  If \code{Sys.unsetenv} is not supported, it will at least try to
61433 ripley 52
  set the value of the environment variable to \code{""}, with a
41571 ripley 53
  warning.
58044 murdoch 54
}
41571 ripley 55
#endif
9925 ripley 56
\seealso{
35977 ripley 57
  \code{\link{Sys.getenv}}, \link{Startup} for ways to set environment
58
  variables for the \R session.
61433 ripley 59
 
9925 ripley 60
  \code{\link{setwd}} for the working directory.
46898 ripley 61
 
62
 
63
  The help for \sQuote{\link{environment variables}} lists many of the
64
  environment variables used by \R.
9925 ripley 65
}
66
\examples{
61153 ripley 67
print(Sys.setenv(R_TEST = "testit", "A+C" = 123))  # `A+C` could also be used
9936 ripley 68
Sys.getenv("R_TEST")
40376 ripley 69
#ifdef windows
70
Sys.unsetenv("R_TEST")
71
#endif
72
#ifdef unix
41571 ripley 73
Sys.unsetenv("R_TEST")  # may warn and not succeed
40376 ripley 74
#endif
61153 ripley 75
Sys.getenv("R_TEST", unset = NA)
9925 ripley 76
}
77
\keyword{environment}
78
\keyword{utilities}