Skip to contents

System path string handlers

Usage

addToPathEnd(x, var = "PATH")

addToPathStart(x, var = "PATH")

removeFromPath(x, var = "PATH")

Arguments

x

character. Elements to add to the system path string defined in var.

var

character(1). System environment variable name. Hands off to Sys.getenv and Sys.setenv internally. Intended for use with "PATH", "FPATH", "MANPATH", etc.

Value

Invisible character(1). Path string.

Functions

  • addToPathEnd: Note that input defined in x is reversed internally, so the first element in the vector is added to the end of the path string.

Note

Updated 2021-08-23.

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"