diff options
author | Ryan Egesdahl <ryan.egesdahl@mongodb.com> | 2020-06-26 11:01:56 -0700 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-07-09 20:28:41 +0000 |
commit | c7348f391124e681d9c62aceb0e13e0d07fca8bc (patch) | |
tree | 96995af1b4ca2ea2513f75fdc6401c7a7afdf454 /site_scons | |
parent | bf3b9a1e6d52dddbb9ed85c113d613ffbc866e13 (diff) | |
download | mongo-c7348f391124e681d9c62aceb0e13e0d07fca8bc.tar.gz |
SERVER-48885 Environment variables values with spaces can cause build failures
If any environment variable (including PATH) were to somehow make its
way into your build.ninja, it would cause build failures due to the fact
that the shell splits it into separate arguments. This can happen
sometimes especially on OSX, where the PATHOSX environment variable gets
(incorrectly) copied by SCons into the current build environment.
Regardless of whatever SCons should be doing, we will quote environment
variable values in Ninja builds to ensure it doesn't happen again.
Diffstat (limited to 'site_scons')
-rw-r--r-- | site_scons/site_tools/ninja_next.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/site_scons/site_tools/ninja_next.py b/site_scons/site_tools/ninja_next.py index cedad091877..b342c5c93d7 100644 --- a/site_scons/site_tools/ninja_next.py +++ b/site_scons/site_tools/ninja_next.py @@ -875,7 +875,13 @@ def get_command_env(env): if windows: command_env += "set '{}={}' && ".format(key, value) else: - command_env += "{}={} ".format(key, value) + # We address here *only* the specific case that a user might have + # an environment variable which somehow gets included and has + # spaces in the value. These are escapes that Ninja handles. This + # doesn't make builds on paths with spaces (Ninja and SCons issues) + # nor expanding response file paths with spaces (Ninja issue) work. + value = value.replace(r' ', r'$ ') + command_env += "{}='{}' ".format(key, value) env["NINJA_ENV_VAR_CACHE"] = command_env return command_env |