diff options
author | Seth R Johnson <johnsonsr@ornl.gov> | 2019-05-07 11:50:07 -0400 |
---|---|---|
committer | Peter Scheibel <scheibel1@llnl.gov> | 2019-05-08 06:36:52 +0900 |
commit | 6cdbc33c90fc347d951d88ec487ca99c6a261dfd (patch) | |
tree | f1427505c2254c93a6961d2977e30db333005a6e | |
parent | e4ce4e5c2c3ae83d24965ed95b3d6cf6aa94b9cf (diff) | |
download | spack-6cdbc33c90fc347d951d88ec487ca99c6a261dfd.tar.gz spack-6cdbc33c90fc347d951d88ec487ca99c6a261dfd.tar.bz2 spack-6cdbc33c90fc347d951d88ec487ca99c6a261dfd.tar.xz spack-6cdbc33c90fc347d951d88ec487ca99c6a261dfd.zip |
Hide some variables in spack-build.env file
Don't arbitrarily reset PWD and OLDPWD when sourcing, as well as other
session-specific IDs
-rw-r--r-- | lib/spack/spack/util/environment.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/spack/spack/util/environment.py b/lib/spack/spack/util/environment.py index b16db85ad9..ef2d2a23b6 100644 --- a/lib/spack/spack/util/environment.py +++ b/lib/spack/spack/util/environment.py @@ -119,10 +119,14 @@ def env_var_to_source_line(var, val): def dump_environment(path, environment=None): """Dump an environment dictionary to a source-able file.""" - use_env = environment if environment else os.environ + use_env = environment or os.environ + hidden_vars = set(['PS1', 'PWD', 'OLDPWD', 'TERM_SESSION_ID']) + with open(path, 'w') as env_file: for var, val in sorted(use_env.items()): - env_file.write('{0}\n'.format(env_var_to_source_line(var, val))) + env_file.write(''.join(['#' if var in hidden_vars else '', + env_var_to_source_line(var, val), + '\n'])) def pickle_environment(path, environment=None): |