[Rd] Evaluate values in `Sys.setenv`
Jeff King
@zwj|08 @end|ng |rom gm@||@com
Fri Aug 28 11:00:53 CEST 2020
Hi all,
I would like to know if there is any way to evaluate the values in
`Sys.setenv` before setting the environment variables. For example, if we
want to add a path to the environment variable `PATH`, we can do this in a
terminal
```
> export PATH=~/mypath:$PATH
> echo $PATH
/Users/jeff/mypath:...
```
However, this style of assignment is not allowed in `Sys.setenv`, it
treats its argument as a literal string, so
```
> Sys.setenv(PATH= " ~/mypath:$PATH")
> Sys.getenv("PATH")
[1] " ~/mypath:$PATH "
```
Note that both the symbol `~` and the variable `$PATH` are not expanded.
While we can manually evaluate the home symbol `~` and PATH using
`Sys.getenv`, the code seems not quite neat. I would like to suggest adding
a parameter in ` Sys.setenv` to make the function more convenient(e.g.
Sys.setenv(..., fixed = TRUE)) if no existing function in base R can do
them in one line.
Best,
Jiefei
[[alternative HTML version deleted]]
More information about the R-devel
mailing list