Skip to content

Substitute environment variables in a python string

License

Notifications You must be signed in to change notification settings

HuanMeng0/python-envsubst

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Substitute environment variables in a python string

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.9%
  • Shell 1.1%