-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use more robust mechanism for unsetting environment variables #4685
Conversation
easybuild/tools/run.py
Outdated
@@ -217,8 +217,10 @@ def create_cmd_scripts(cmd_str, work_dir, env, tmpdir, out_file, err_file): | |||
with open(env_fp, 'w') as fid: | |||
# unset all environment variables in current environment first to start from a clean slate; | |||
# we need to be careful to filter out functions definitions, so first undefine those | |||
fid.write("unset -f $(env | grep '%=' | cut -f1 -d'%' | sed 's/BASH_FUNC_//g')\n") | |||
fid.write("unset $(env | cut -f1 -d=)\n") | |||
fid.write("for var in $(compgen -e); do\n unset \"$var\"\ndone\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Micket This is really hard to read, how about this instead? (and then similar below)
fid.write('\n'.join([
'for var in $(compgen -e); do',
' unset "$var"',
'done',
]) + '\n')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done force pushed
Parsing the output of "env" can be fragile for certain complex environment. Using compgen should be safer.
…of environment more robust
Did the test just hang and die? There is no output in the CI, just a red mark that it failed the tests for one particular python version. |
For which commit? For last commit, it's all green... |
Parsing the output of "env" can be fragile for certain complex environment.
Using compgen should be safer.