diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-10-08 19:29:14 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-10-13 19:43:07 +0100 |
commit | 08aa8ad930c1488285263145f01c7e8a9dca59dc (patch) | |
tree | 1406b9f59c5aa11f2ec954167f16980eeea87d10 /share | |
parent | 09983e35984755339ce379e41d6f9dcd5587f7bf (diff) | |
download | subplot-08aa8ad930c1488285263145f01c7e8a9dca59dc.tar.gz |
templates: Inherit environment for the most part
We inherit all the environment except we override a few variables
in order to provide some level of consistency.
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'share')
-rw-r--r-- | share/bash/template/template.sh.tera | 14 | ||||
-rw-r--r-- | share/python/template/scenarios.py | 6 |
2 files changed, 3 insertions, 17 deletions
diff --git a/share/bash/template/template.sh.tera b/share/bash/template/template.sh.tera index da748be..12d72ea 100644 --- a/share/bash/template/template.sh.tera +++ b/share/bash/template/template.sh.tera @@ -163,20 +163,8 @@ scenario_{{ loop.index }}() { {% endfor %} ############################################################################# -# Make the environment minimal. - -# Write to stdout the names of all environment variables, one per -# line. Handle also cases where the value of an environment variable -# contains newlines. -envnames() -{ - env -0 | sed -z 's/^\([^=]\+\)=.*$/\1/' | tr '\0' '\n' -} +# Update the environment -# Unset all environment variables. At the beginning of each scenario, -# some additional ones will be set to the per-scenario directory. -unset $(envnames) -export PATH=/bin:/usr/bin export SHELL=/bin/sh # Include any configured environment variables diff --git a/share/python/template/scenarios.py b/share/python/template/scenarios.py index 96dcc69..b215133 100644 --- a/share/python/template/scenarios.py +++ b/share/python/template/scenarios.py @@ -83,15 +83,13 @@ class Scenario: def _set_environment_variables_to(self, scendir, extra_env): log_value = globals()["log_value"] - minimal = { - "PATH": "/bin:/usr/bin", + overrides = { "SHELL": "/bin/sh", "HOME": scendir, "TMPDIR": scendir, } - os.environ.clear() - os.environ.update(minimal) + os.environ.update(overrides) os.environ.update(extra_env) if not self._logged_env: self._logged_env = True |