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.

Source Distribution

envsubst-0.1.4.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

envsubst-0.1.4-py2.py3-none-any.whl (3.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file envsubst-0.1.4.tar.gz.

File metadata

  • Download URL: envsubst-0.1.4.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.0

File hashes

Hashes for envsubst-0.1.4.tar.gz
Algorithm Hash digest
SHA256 579c56e0eeaa9a6798006daef6232e48c1c817628e9cc24df92c224e3af2e310
MD5 84a402ee766d0489f7a86692b6987467
BLAKE2b-256 aefbf27fcf13a822d80b317cbe84044df83a31c96a5bf884dead4a28fdaa4c05

See more details on using hashes here.

File details

Details for the file envsubst-0.1.4-py2.py3-none-any.whl.

File metadata

  • Download URL: envsubst-0.1.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.0

File hashes

Hashes for envsubst-0.1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0cff54bb1318f4d2b234e9cf106d8c74a358ca3e84a16d36eadf2cf64086dc56
MD5 0008f1d89b54fe3f0d0efb0a3c682434
BLAKE2b-256 296b287e381277c0947bcf4dc5e19fe9a2f7a714e0026042550cf00f3885a8ba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page