From 6cdbc33c90fc347d951d88ec487ca99c6a261dfd Mon Sep 17 00:00:00 2001 From: Seth R Johnson Date: Tue, 7 May 2019 11:50:07 -0400 Subject: Hide some variables in spack-build.env file Don't arbitrarily reset PWD and OLDPWD when sourcing, as well as other session-specific IDs --- lib/spack/spack/util/environment.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') 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): -- cgit v1.2.3-60-g2f50