Debian Codegraph @

man/set_envvar.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/utils.R
3 \name{set_envvar}
4 \alias{set_envvar}
5 \title{Set environment variables}
6 \usage{
7 set_envvar(vars)
8 }
9 \arguments{
10 \item{vars}{A named character vector of the form \code{c(VARIABLE = VALUE)}.
11 If any value is \code{NA}, this function will try to unset the variable.}
12 }
13 \value{
14 Old values of the variables (if not set, \code{NA}).
15 }
16 \description{
17 Set environment variables from a named character vector, and return the old
18 values of the variables, so they could be restored later.
19 }
20 \details{
21 The motivation of this function is that \code{\link[=Sys.setenv]{Sys.setenv()}} does not
22 return the old values of the environment variables, so it is not
23 straightforward to restore the variables later.
24 }
25 \examples{
26 vars = xfun::set_envvar(c(FOO = "1234"))
27 Sys.getenv("FOO")
28 xfun::set_envvar(vars)
29 Sys.getenv("FOO")
30 }