Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 594 Bytes

README.rst

File metadata and controls

23 lines (16 loc) · 594 Bytes

python-envsubst

Substitute environment variables in a string:

>>> import os
>>> from envsubst import envsubst

>>> del os.environ['PS1']
>>> print(envsubst('$USER@$HOST ${PS1:-$}:'))
[email protected] $:

>>> os.environ['PS1'] = ''
>>> print(envsubst('$USER@$HOST ${PS1:-$}:'))
[email protected] $:

>>> print(envsubst('$USER@$HOST ${PS1-foo}:'))
[email protected] :

>>> os.environ['DEFAULT_PROMPT'] = '$'
>>> print(envsubst('$USER@$HOST ${PS1:-$DEFAULT_PROMPT}:'))

Also supports $0, $1, etc. from argv.