diff options
author | alalazo <massimiliano.culpo@googlemail.com> | 2016-06-18 13:39:08 +0200 |
---|---|---|
committer | alalazo <massimiliano.culpo@googlemail.com> | 2016-06-18 13:39:08 +0200 |
commit | 9e0c20c794cea3d54fc16ea7470035384985f1c6 (patch) | |
tree | 31b3969a80056f8b7a7c044ad0ac220e39f70cf1 /lib | |
parent | a17d1efe7c738d08718fb46ae7a04d52c1a63dc1 (diff) | |
download | spack-9e0c20c794cea3d54fc16ea7470035384985f1c6.tar.gz spack-9e0c20c794cea3d54fc16ea7470035384985f1c6.tar.bz2 spack-9e0c20c794cea3d54fc16ea7470035384985f1c6.tar.xz spack-9e0c20c794cea3d54fc16ea7470035384985f1c6.zip |
environment : filter the current environment
Previously only the environment obtained after sourcing the file was filtered.
This caused the appeareance of spurious unset commands in the list.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/environment.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py index cfba060459..30c6228ca4 100644 --- a/lib/spack/spack/environment.py +++ b/lib/spack/spack/environment.py @@ -297,16 +297,18 @@ class EnvironmentModifications(object): if proc.returncode != 0: raise RuntimeError('sourcing files returned a non-zero exit code') output = ''.join([line for line in proc.stdout]) - # Construct a dictionary with all the variables in the environment + # Construct a dictionary with all the variables in the new environment after_source_env = dict(json.loads(output)) + this_environment = dict(os.environ) - # Filter variables that are due to how we source - after_source_env.pop('SHLVL') - after_source_env.pop('_') - after_source_env.pop('PWD') + # Filter variables that are not related to sourcing a file + to_be_filtered = 'SHLVL', '_', 'PWD', 'OLDPWD' + for d in after_source_env, this_environment: + for name in to_be_filtered: + d.pop(name, None) # Fill the EnvironmentModifications instance - this_environment = dict(os.environ) + # New variables new_variables = set(after_source_env) - set(this_environment) for x in new_variables: |