diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-02-20 23:10:34 +0530 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-03-21 09:10:04 +0000 |
commit | e714202055483286d77467ec7f393ad23c8683c8 (patch) | |
tree | 2fd35399b435b1f1f2a01ae4dbc98a749e0c2778 /giscanner/ccompiler.py | |
parent | c942279c7c5e2b42c2f060372e15cbf54a5c353f (diff) | |
download | gobject-introspection-e714202055483286d77467ec7f393ad23c8683c8.tar.gz |
giscanner: Use shlex.split() for environment variables
str.split() does not handle quoting, so if you have spaces in your
CFLAGS, it will be split incorrectly. For instance:
CFLAGS="'-I/opt/some dir' -DFOO=bar"
>>> os.environ['CFLAGS'].split()
["'-I/opt/some", "dir'", '-DFOO=bar']
>>> shlex.split(os.environ['CFLAGS'])
['-I/opt/some dir', '-DFOO=bar']
https://bugzilla.gnome.org/show_bug.cgi?id=778971
Diffstat (limited to 'giscanner/ccompiler.py')
-rw-r--r-- | giscanner/ccompiler.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py index 11bc9fc4..7c1895da 100644 --- a/giscanner/ccompiler.py +++ b/giscanner/ccompiler.py @@ -19,6 +19,7 @@ # import os +import shlex import subprocess import tempfile @@ -213,7 +214,7 @@ class CCompiler(object): # This is to handle the case where macros are defined in CFLAGS cflags = os.environ.get('CFLAGS') if cflags: - for i, cflag in enumerate(cflags.split()): + for i, cflag in enumerate(shlex.split(cflags)): if cflag.startswith('-D'): stridx = cflag.find('=') if stridx > -1: |