\HeaderA{Sys.setenv}{Set or Unset Environment Variables}{Sys.setenv}
\aliasA{Sys.unsetenv}{Sys.setenv}{Sys.unsetenv}
\keyword{environment}{Sys.setenv}
\keyword{utilities}{Sys.setenv}
\begin{Description}\relax
\code{Sys.setenv} sets environment variables (for other processes
called from within \R{} or future calls to \code{\LinkA{Sys.getenv}{Sys.getenv}} from
this \R{} process).

\code{Sys.unsetenv} removes environment variables.
\end{Description}
\begin{Usage}
\begin{verbatim}
Sys.setenv(...)

Sys.unsetenv(x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{...}] named arguments with values coercible to a character string.
\item[\code{x}] a character vector, or an object coercible to character.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The names \code{setenv} and \code{putenv} come from different Unix
traditions: \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 names
containing \code{"="}.
\end{Details}
\begin{Value}
A logical vector, with elements being true if (un)setting the
corresponding variable succeeded.  (For \code{Sys.unsetenv} this
includes attempting to remove a non-existent variable.)
\end{Value}
\begin{Note}\relax
Not all systems need support \code{Sys.setenv} (although all known
current platforms do) nor \code{Sys.unsetenv}.
If \code{Sys.unsetenv} is not supported, it will at least try to
set the value of the environment variable to \code{""}, with a 
warning.
\end{Note}
\begin{SeeAlso}\relax
\code{\LinkA{Sys.getenv}{Sys.getenv}}, \LinkA{Startup}{Startup} for ways to set environment
variables for the \R{} session.

\code{\LinkA{setwd}{setwd}} for the working directory.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
print(Sys.setenv(R_TEST="testit", "A+C"=123))  # `A+C` could also be used
Sys.getenv("R_TEST")
Sys.unsetenv("R_TEST")  # may warn and not succeed
Sys.getenv("R_TEST", unset=NA)
\end{ExampleCode}
\end{Examples}

