[Scons-users] Command-line argument escaping doesn't fully respect parentheses or single quotes
Abigail Bunyan
abigail.bunyan at microsoft.com
Thu Aug 1 05:46:53 EDT 2019
The following SConstruct fails to compile on POSIX, with SCons 2.3.0 to 3.1.0:
env = Environment()
env.Tool("textfile")
env.Textfile("test.c", ["int main() { return foo(0); }"])
env.Append(CPPDEFINES={"foo(x)": "x"})
env.Program("test", "test.c")
The error is:
gcc -o test.o -c -Dfoo(x)=x test.c
sh: 1: Syntax error: "(" unexpected
scons: *** [test.o] Error 2
It's possible to work around it by adding our own escaping - meaning that these
quotes aren't being properly escaped either:
env.Append(CPPDEFINES={"'foo(x)'": "x"})
I don't know if the escaping that SCons applies is insufficient, or it's not
applying it at all in this case, or if it shouldn't be using `sh` and should
just directly be calling `gcc`. It looks like src/engine/SCons/Platform/posix.py
has had a lot of changes related to escaping over the years.
More information about the Scons-users
mailing list