Learn R Programming

options (version 0.3.0)

envvar_fns: Generator functions for environment variable processors

Description

These functions return environment variable processor functions. Arguments to them are used to specify behaviors.

Usage

envvar_is(value, ...)

# S3 method for `NULL` envvar_is(value, case_sensitive = FALSE, ...)

# S3 method for character envvar_is(value, case_sensitive = FALSE, ...)

# S3 method for numeric envvar_is(value, ...)

# S3 method for logical envvar_is(value, case_sensitive = FALSE, ...)

envvar_eval(...)

envvar_eval_or_raw(...)

envvar_is_one_of(values, ...)

envvar_choice_of(values, default = NULL, ...)

envvar_is_true(...)

envvar_is_false(...)

envvar_is_set(...)

envvar_str_split(delim = ";", ...)

Value

A function to be used for processing an environment variable value

Arguments

value

A value to test against

...

Other arguments unused

case_sensitive

A logical value indicating whether string comparisons should be case-sensitive.

values

A list or vector of values to match

default

A default value used when a value cannot be coerced from the environment variable value

delim

A character value to use as a delimiter to use when splitting the environment variable value

Functions

  • envvar_is(): Test for equality with handlers for most atomic R types, performing sensible interpretation of environment variable values.

  • envvar_is(`NULL`): environment variable has value "null"

  • envvar_is(character): environment variable is equal to string value

  • envvar_is(numeric): environment variable is equal to string representation of numeric value

  • envvar_is(logical): environment variable is equal to string representation of logical value

  • envvar_eval(): Parse the environment variable value as R code and and evaluate it to produce a return value, emitting an error if the expression fails to parse or evaluate. This option is a sensible default for most R-specific environment variables, but may fail for string literals, and meaningful values that don't conform to R's syntax like "true" (see envvar_is_true()), "false" (see envvar_is_false()) or "null".

  • envvar_eval_or_raw(): Parse the environment variable value as R code and and evaluate it to produce a return value, or falling back to the raw value as a string if an error occurs.

  • envvar_is_one_of(): For meaningful string comparisons, check whether the environment variable is equal to some meaningful string. Optionally with case-sensitivity.

  • envvar_choice_of(): Check whether environment variable can be coerced to match one of values, returning the value if it matches or default otherwise.

  • envvar_is_true(): Test whether the environment variable is "truthy", that is whether it is case-insensitive "true" or 1

  • envvar_is_false(): Test whether the environment variable is "falsy", that is whether it is case-insensitive "false" or 0

  • envvar_is_set(): Test whether the environment variable is set. This is somewhat operating-system dependent, as not all operating systems can distinguish between an empty string as a value and an unset environment variable. For details see Sys.getenv()'s Details about its unset parameter.

  • envvar_str_split(): Interpret the environment variable as a delimited list of strings, such as PATH variables.