Skip to content

Commit

Permalink
merge from devel
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-merzky committed Aug 20, 2024
2 parents 4b5a969 + 3a891bf commit dbcc290
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/radical/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# we know that some env vars are not worth preserving. We explicitly exclude
# those which are common to have complex syntax and need serious caution on
# shell escaping:
BLACKLIST = ['PS1', 'LS_COLORS', '_', 'SHLVL', 'PROMPT_COMMAND']
IGNORE_LIST = ['PS1', 'LS_COLORS', '_', 'SHLVL', 'PROMPT_COMMAND']

# Identical task `pre_exec_cached` settings will result in the same environment
# settings, so we cache those environments here. We rely on a hash to ensure
Expand Down Expand Up @@ -72,13 +72,13 @@ def env_write(script_path, env, unset=None, blacklist=None, pre_exec=None):
data += 'unset %s\n' % k
data += '\n'

if BLACKLIST:
if IGNORE_LIST:
data += '# blacklist\n'
for k in sorted(BLACKLIST):
for k in sorted(IGNORE_LIST):
data += 'unset %s\n' % k
data += '\n'

env = {k: v for k, v in env.items() if k not in BLACKLIST}
env = {k: v for k, v in env.items() if k not in IGNORE_LIST}

if blacklist:
data += '# blacklist\n'
Expand Down Expand Up @@ -164,7 +164,7 @@ def env_read_lines(lines: List[str]) -> Dict[str, str]:
if re_snake_case.match(this_key):
# valid key - store previous key/val if we have any, and
# initialize `key` and `val`
if key and key not in BLACKLIST:
if key and key not in IGNORE_LIST:
env[key] = val

key = this_key
Expand All @@ -173,7 +173,7 @@ def env_read_lines(lines: List[str]) -> Dict[str, str]:
elif re_bash_function.match(this_key):
# function definitions
# initialize `key` and `val`
if key and key not in BLACKLIST:
if key and key not in IGNORE_LIST:
env[key] = val

key = this_key
Expand All @@ -185,7 +185,7 @@ def env_read_lines(lines: List[str]) -> Dict[str, str]:
val += line

# store last key/val if we have any
if key and key not in BLACKLIST:
if key and key not in IGNORE_LIST:
env[key] = val

return env
Expand Down Expand Up @@ -444,7 +444,7 @@ def env_diff(env_1 : Dict[str,str],
those elements which appear in only either one or the other env, and which
changed from one env to another.
It will ignore any keys in the `BLACKLIST` and will also ignore
It will ignore any keys in the `IGNORE_LIST` and will also ignore
`BASH_FUNC_*` keys which point to bash function definitions.
'''

Expand All @@ -456,7 +456,7 @@ def env_diff(env_1 : Dict[str,str],
keys_2 = sorted(env_2.keys())

for k in keys_1:
if k in BLACKLIST:
if k in IGNORE_LIST:
continue
if k.startswith('BASH_FUNC_'):
continue
Expand All @@ -465,7 +465,7 @@ def env_diff(env_1 : Dict[str,str],
elif v != env_2[k] : changed[k] = [v, env_2[k]]

for k in keys_2:
if k in BLACKLIST:
if k in IGNORE_LIST:
continue
if k.startswith('BASH_FUNC_'):
continue
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_env_read():
assert os.environ[k] == v, [k, os.environ[k], v]

for k,v in os.environ.items():
if k not in ru.env.BLACKLIST:
if k not in ru.env.IGNORE_LIST:
if k.startswith('BASH_FUNC_'):
# bash funcs are not exported to other shells
continue
Expand Down

0 comments on commit dbcc290

Please sign in to comment.