Module env

Copyright © 2012 Serge Aleynikov

Authors: Serge Aleynikov (saleyn@gmail.com).

Description

Environment utils

Function Index

get_env/3Get application configuration.
home_dir/0
normalize_path/1
replace_env_vars/1Perform replacement of environment variable values in the OsPath.
replace_env_vars/2Perform replacement of environment variable values in the OsPath.
subst_env_path/1
subst_env_path/2

Function Details

get_env/3

get_env(App :: atom(), Key :: atom(), Default :: any()) -> any()

Get application configuration

home_dir/0

home_dir() -> any()

normalize_path/1

normalize_path(Path) -> any()

replace_env_vars/1

replace_env_vars(OsPath :: 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 also: os:getenv/1.

replace_env_vars/2

replace_env_vars(OsPath :: list() | binary(),
                 Bindings :: [{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 also: os:getenv/1.

subst_env_path/1

subst_env_path(OsPath :: list() | binary()) -> list() | binary()

subst_env_path/2

subst_env_path(OsPath :: list() | binary(),
               Bindings :: [{atom() | string(), string()}]) ->
                  list() | binary()