Get Environment Variables

DESCRIPTION:
Returns the values of environment variables.

USAGE:
getenv(var)

OPTIONAL ARGUMENTS:
var:
vector of character strings giving the names of the environment variables whose values are sought. Environment variables are in all capital letters by convention in UNIX; they are forced to be in all capitals in DOS. If var is missing, the entire environment is returned.

VALUE:
vector of character strings giving the values of the environment variables named in var, or the values of all environment variables if var is omitted. If an element of var is not the name of an environment variable, the corresponding element of the returned vector will be the null string ("").

In all cases, the returned vector has a names attribute which holds the variable names.


BACKGROUND:
S-PLUS uses several environment variables, such as those in the example section. This function can be used to retrieve the value of any environment variable, not just those set by S-PLUS.

EXAMPLES:
getenv("HOME")
getenv("S_PRINT_ORIENTATION") # might return "landscape" (on Unix)
shome <- "SHOME"
getenv(shome) # returns character string of the S-PLUS home directory
all.env <- getenv()  # whole environment
leading.S <- grep("^S", names(all.env))
    # index into all.env for those names starting with 'S'
all.env[leading.S]
    # values of these variables; names are preserved
getenv(c("S_PATH", "S_FIRST"))
getenv()[c("S_PATH", "S_FIRST")]   # same thing