Skip to main content

Substitute environment variables in a string

Project description

Substitute environment variables in a string:

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

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

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

>>> print(envsubst('$USER@$HOST ${PS1-foo}:'))
ashafer01@github.com :

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for envsubst, version 0.1.5
Filename, size File type Python version Upload date Hashes
Filename, size envsubst-0.1.5-py2.py3-none-any.whl (4.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size envsubst-0.1.5.tar.gz (2.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page