R/envvar_is_set.R

Defines functions envvar_is_set

Documented in envvar_is_set

#' @rdname envvar_is_set
#' @title Check whether an environment variable is set
#'
#' @description `envvar_is_set()` checks whether a given environment variable is
#' set.
#' @param x String with the name of environment variable
#'
#' @return A logical value
#' @export
#'
#' @examples
#' envvar_is_set("HOME")
envvar_is_set <- function(x) {
  assert_scalar_string(x)
  !rlang::is_na(Sys.getenv(x, unset = NA_character_))
}

Try the envvar package in your browser

Any scripts or data that you put into this service are public.

envvar documentation built on Sept. 11, 2024, 8:29 p.m.