Command-line argument escaping doesn't fully respect parentheses or single quotes

Abigail Bunyan via Scons-users <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <DB7PR83MB0252EC4BC6DA3C41E4EEADDF89DE0@DB7PR83MB0252.EURPRD83.prod.outlook.com>
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.
_______________________________________________
Scons-users mailing list
[email protected]
https://pairlist4.pair.net/mailman/listinfo/scons-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.