Rev 41571 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{Sys.setenv}\alias{Sys.setenv}\alias{Sys.unsetenv}\title{Set or Unset Environment Variables}\usage{Sys.setenv(\dots)Sys.unsetenv(x)}\arguments{\item{\dots}{named arguments with values coercible to a character string.}\item{x}{a character vector, or an object coercible to character.}}\description{\code{Sys.setenv} sets environment variables (for other processescalled from within \R or future calls to \code{\link{Sys.getenv}} fromthis \R process).\code{Sys.unsetenv} removes environment variables.}\value{A logical vector, with elements being true if (un)setting thecorresponding variable succeeded. (For \code{Sys.unsetenv} thisincludes attempting to remove a non-existent variable.)}\details{The names \code{setenv} and \code{putenv} come from different Unixtraditions: \R also has \code{Sys.putenv}, but this is now deprecated.The internal code uses \code{setenv} if available, otherwise \code{putenv}.Non-standard \R names must be quoted in \code{Sys.setenv}:see the examples. Most platforms (and POSIX) do not allow namescontaining \code{"="}.#ifdef Windows(Windows does, but the facilities provided by \R may not handle thesecorrectly so they should be avoided.)#endif}\note{Not all systems need support \code{Sys.setenv} (although all knowncurrent platforms do) nor \code{Sys.unsetenv}.#ifdef windowsBoth are provided on Windows (although C-level \code{unsetenv} is notavailable).#endif#ifdef unixIf \code{Sys.unsetenv} is not supported, it will at least try toset the value of the environment variable to \code{""}, with awarning.#endif}\seealso{\code{\link{Sys.getenv}}, \link{Startup} for ways to set environmentvariables for the \R session.\code{\link{setwd}} for the working directory.}\examples{print(Sys.setenv(R_TEST="testit", "A+C"=123)) # `A+C` could also be usedSys.getenv("R_TEST")#ifdef windowsSys.unsetenv("R_TEST")#endif#ifdef unixSys.unsetenv("R_TEST") # may warn and not succeed#endifSys.getenv("R_TEST", unset=NA)}\keyword{environment}\keyword{utilities}