Bug 1455065 - Shell quote environment variable values when dumping them in dump_env.py. r?build draft
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 19 Apr 2018 07:26:28 +0900
changeset 784647 00ebadf1808d57ebc55421ecb737b39e6d7159ae
parent 784524 0e45c13b34e815cb42a9f08bb44142d1a81e186e
push id107005
push userbmo:mh+mozilla@glandium.org
push dateWed, 18 Apr 2018 22:28:59 +0000
reviewersbuild
bugs1455065, 818377
milestone61.0a1
Bug 1455065 - Shell quote environment variable values when dumping them in dump_env.py. r?build The mozconfig output parsing code already handles shell quoted strings to some extent (except for bug 818377), because that's what `set` outputs. By quoting environment variable values, we avoid a bunch of problems with "weird" values.
python/mozbuild/mozbuild/action/dump_env.py
--- a/python/mozbuild/mozbuild/action/dump_env.py
+++ b/python/mozbuild/mozbuild/action/dump_env.py
@@ -1,10 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # We invoke a Python program to dump our environment in order to get
 # native paths printed on Windows so that these paths can be incorporated
 # into Python configure's environment.
 import os
+import sys
+
+sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
+
+from shellutil import quote
+
 for key, value in os.environ.items():
-    print('%s=%s' % (key, value))
+    print('%s=%s' % (key, quote(value)))