System path string handlers
Arguments
- x
character
. Elements to add to the system path string defined invar
.- var
character(1)
. System environment variable name. Hands off toSys.getenv
andSys.setenv
internally. Intended for use with"PATH"
,"FPATH"
,"MANPATH"
, etc.
Functions
addToPathEnd()
: Note that input defined inx
is reversed internally, so the first element in the vector is added to the end of the path string.
Examples
x <- c("/usr/local/bin", "/usr/bin")
var <- "TESTPATH"
Sys.unsetenv(var)
addToPathEnd(x = x, var = var)
Sys.getenv(var)
#> [1] "/usr/bin:/usr/local/bin"
removeFromPath(x = x, var = var)
Sys.getenv(var)
#> [1] ""
addToPathStart(x = x, var = var)
Sys.getenv(var)
#> [1] "/usr/local/bin:/usr/bin"