\HeaderA{Sys.getenv}{Get Environment Variables}{Sys.getenv}
\keyword{environment}{Sys.getenv}
\keyword{utilities}{Sys.getenv}
\begin{Description}\relax
\code{Sys.getenv} obtains the values of the environment variables.
\end{Description}
\begin{Usage}
\begin{verbatim}
Sys.getenv(x = NULL, unset = "")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a character vector, or \code{NULL}.
\item[\code{unset}] a character string.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Both arguments will be coerced to character if necessary.

Setting \code{unset = NA} will enable unset variables and those set to
the value \code{""} to be distinguished, \emph{if the OS does}.
\end{Details}
\begin{Value}
A vector of the same length as \code{x}, with the variable names as
its \code{names} attribute.  Each element holds the value of the
environment variable named by the corresponding component of \code{x}
(or the value of \code{unset} if no environment variable with that
name was found).

On most platforms \code{Sys.getenv()} will return a named vector giving
the values of all the environment variables, sorted in the current
locale.  It may be confused by names containing \code{=} which some
platforms allow but POSIX does not.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{Sys.setenv}{Sys.setenv}},
\code{\LinkA{Sys.getlocale}{Sys.getlocale}} for the locale in use,
\code{\LinkA{getwd}{getwd}} for the working directory.

The help for \sQuote{\LinkA{environment variables}{environment variables}} lists many of the
environment variables used by \R.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## whether HOST is set will be shell-dependent e.g. Solaris' csh does not.
Sys.getenv(c("R_HOME", "R_PAPERSIZE", "R_PRINTCMD", "HOST"))

names(s <- Sys.getenv()) # all settings (the values could be very long)

## Language and Locale settings -- but rather use Sys.getlocale()
s[grep("^L(C|ANG)", names(s))]
\end{ExampleCode}
\end{Examples}

