Rev 84589 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/base/man/Sys.getenv.Rd% Part of the R package, https://www.R-project.org% Copyright 1995-2014 R Core Team% Distributed under GPL 2 or later\name{Sys.getenv}\title{Get Environment Variables}\usage{Sys.getenv(x = NULL, unset = "", names = NA)}\alias{Sys.getenv}\arguments{\item{x}{a character vector, or \code{NULL}.}\item{unset}{a character string.}\item{names}{logical: should the result be named? If \code{NA} (thedefault) single-element results are not named whereas multi-elementresults are.}}\description{\code{Sys.getenv} obtains the values of the environment variables.}\details{Both arguments will be coerced to character if necessary.Setting \code{unset = NA} will enable unset variables and those set tothe value \code{""} to be distinguished, \emph{if the OS does}. POSIXrequires the OS to distinguish, and all known current \R platforms do.}\value{A vector of the same length as \code{x}, with (if \code{names ==TRUE}) the variable names as its \code{names} attribute. Each elementholds the value of the environment variable named by the correspondingcomponent of \code{x} (or the value of \code{unset} if no environmentvariable with that name was found).On most platforms \code{Sys.getenv()} will return a named vectorgiving the values of all the environment variables, sorted in thecurrent locale. It may be confused by names containing \code{=} whichsome platforms allow but POSIX does not. (Windows is such a platform:there names including \code{=} are truncated just before the first\code{=}.)When \code{x} is missing and \code{names} is not false, the result isof class \code{"Dlist"} in order to get a nice\code{\link{print}} method.}\seealso{\code{\link{Sys.setenv}},\code{\link{Sys.getlocale}} for the locale in use,\code{\link{getwd}} for the working directory.The help for \sQuote{\link{environment variables}} lists many of theenvironment variables used by \R.}\examples{\dontdiff{## whether HOST is set will be shell-dependent e.g. Solaris' csh did not.Sys.getenv(c("R_HOME", "R_PAPERSIZE", "R_PRINTCMD", "HOST"))s <- Sys.getenv() # *all* environment variablesop <- options(width=111) # (nice printing)names(s) # all settings (the values could be very long)head(s, 12) # using the Dlist print() method## Language and Locale settings -- but rather use Sys.getlocale()s[grep("^L(C|ANG)", names(s))]## typically R-related:s[grep("^_?R_", names(s))]options(op)# reset}}\keyword{environment}\keyword{utilities}