Env file
Index¶
- env_file::_assert_valid_var_name
- env_file::assert_var_exists
- env_file::get_var_value
- env_file::is_var_value_empty
- env_file::set_var_value
- env_file::set_var_value_if_empty
- env_file::prompt_var_value
- env_file::prompt_var_value_if_empty
- env_file::prompt_value_with_default
- env_file::prompt_value_with_default_if_empty
- env_file::prompt_pw_value
- env_file::prompt_pw_with_symbols_value
- env_file::prompt_pw_value_if_empty
- env_file::prompt_pw_with_symbols_value_if_empty
env_file::_assert_valid_var_name¶
Die if the given env var name is not a valid shell-style identifier.
Closes regex-injection in ^${var_name}= patterns used throughout this file.
Arguments¶
- $1 (candidate): variable name
env_file::assert_var_exists¶
Die if the given variable does not exist as a key in the env file.
Arguments¶
- $1 (env): file path
- $2 (variable): name
Exit codes¶
- 0: if true
- 1: if false
env_file::get_var_value¶
Print the value of a variable from an env file. Output: stdout — the variable's value (may be empty)
Arguments¶
- $1 (env): file path
- $2 (variable): name
env_file::is_var_value_empty¶
Return true if the given variable exists in the env file but has an empty value.
Arguments¶
- $1 (env): file path
- $2 (variable): name
Exit codes¶
- 0: if true
- 1: if false
env_file::set_var_value¶
Set the value of a variable in an env file, overwriting any existing value.
Arguments¶
- $1 (env): file path
- $2 (variable): name
- $3 (new): value
env_file::set_var_value_if_empty¶
Set the value of a variable in an env file only if its current value is empty.
Arguments¶
- $1 (env): file path
- $2 (variable): name
- $3 (new): value
env_file::prompt_var_value¶
Interactively prompt the user for a value and write it to a variable in an env file.
Arguments¶
- $1 (env): file path
- $2 (variable): name
- $3 (variable): info shown in prompt (optional)
- $4 (default): value pre-filled in prompt (optional)
env_file::prompt_var_value_if_empty¶
Interactively prompt for a value and write it to a variable in an env file, only if currently empty.
Arguments¶
- $1 (env): file path
- $2 (variable): name
- $3 (variable): info shown in prompt (optional)
- $4 (default): value pre-filled in prompt (optional)
env_file::prompt_value_with_default¶
Prompt for a value with a required default and write it to a variable in an env file.
Arguments¶
- $1 (env): file path
- $2 (variable): name
- $3 (default): value
env_file::prompt_value_with_default_if_empty¶
Prompt for a value with a default and write it to a variable in an env file, only if currently empty.
Arguments¶
- $1 (env): file path
- $2 (variable): name
- $3 (default): value
env_file::prompt_pw_value¶
Prompt for a password value (pre-filled with a generated password) and write it to a variable in an env file.
Arguments¶
- $1 (env): file path
- $2 (variable): name
- $3 (variable): info shown in prompt (optional)
env_file::prompt_pw_with_symbols_value¶
Prompt for a password-with-symbols value (pre-filled with a generated password) and write it to a variable.
Arguments¶
- $1 (env): file path
- $2 (variable): name
- $3 (variable): info shown in prompt (optional)
env_file::prompt_pw_value_if_empty¶
Prompt for a password value and write it to a variable in an env file, only if currently empty.
Arguments¶
- $1 (env): file path
- $2 (variable): name
- $3 (variable): info shown in prompt (optional)
env_file::prompt_pw_with_symbols_value_if_empty¶
Prompt for a password-with-symbols value and write it to a variable in an env file, only if currently empty.
Arguments¶
- $1 (env): file path
- $2 (variable): name
- $3 (variable): info shown in prompt (optional)