env (util v1.3.5)

View Source

Environment utils

Author: Serge Aleynikov saleyn@gmail.com Copyright: 2012 Serge Aleynikov

Summary

Functions

Get application configuration

Perform replacement of environment variable values in the OsPath.

Perform replacement of environment variable values in the OsPath. This function also allows to provide a list of Bindings that override the environment (they are checked before environment variables are looked up).

Functions

get_env(App, Key, Default)

-spec get_env(atom(), atom(), any()) -> any().

Get application configuration

home_dir()

normalize_path(Path)

replace_env_vars(OsPath)

-spec replace_env_vars(list() | binary()) -> list() | binary().

Perform replacement of environment variable values in the OsPath.

Example:
  env:replace_env_vars("~/app")       -> "/home/cuser/app"
  env:replace_env_vars("${HOME}/app") -> "/home/cuser/app"
  env:replace_env_vars("$USER/app")   -> "cuser/app"

See: os:getenv/1.

replace_env_vars(OsPath, Bindings)

-spec replace_env_vars(list() | binary(), [{atom() | string(), string()}]) -> list() | binary().

Perform replacement of environment variable values in the OsPath. This function also allows to provide a list of Bindings that override the environment (they are checked before environment variables are looked up).

Example:
  env:replace_env_vars("~/",   [{"HOME", "/home/cu"}]) -> "/home/cu/"
  env:replace_env_vars("~/",   [{home,   "/home/cu"}]) -> "/home/cu/"
  env:replace_env_vars("$A/",  [{a, "/aaa"}]) -> "/aaa/"
  env:replace_env_vars("${A}/",[{a, "/aaa"}]) -> "/aaa/"

See: os:getenv/1.

subst_env_path(OsPath)

This function is deprecated. env:subst_env_path/1 is deprecated; use replace_env_vars/1 instead.
-spec subst_env_path(list() | binary()) -> list() | binary().

subst_env_path(OsPath, Bindings)

This function is deprecated. env:subst_env_path/2 is deprecated; use replace_env_vars/2 instead.
-spec subst_env_path(list() | binary(), [{atom() | string(), string()}]) -> list() | binary().