Skip to content

Commit

Permalink
Expose environment variables from R process (#507)
Browse files Browse the repository at this point in the history
* Expose env vars from R process

* Apply suggestions from code review by @jennybc

Co-authored-by: Jennifer (Jenny) Bryan <[email protected]>

* Update docs for function

* Get specific env vars by name (or all of them)

* Need `names` for single env var

---------

Co-authored-by: Jennifer (Jenny) Bryan <[email protected]>
  • Loading branch information
juliasilge and jennybc authored Sep 11, 2024
1 parent 526abac commit 6dc1977
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/ark/src/modules/positron/system.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ has_x11 <- function() {
out <- as.list(vapply(cats, Sys.getlocale, "string", USE.NAMES = TRUE))
c(LANG = Sys.getenv("LANG"), out)
}

#' Reports a list of environment variables for the R process.
#' @param x A character vector of environment variables. The default `NULL`
#' will return *all* environment variables.
#' @returns Values of the environment variables as a list.
#' @export
.ps.rpc.get_env_vars <- function(x = NULL) {
as.list(Sys.getenv(x, names = TRUE))
}

0 comments on commit 6dc1977

Please sign in to comment.