0

I have a Visual Studio Code tasks.json file to run a C++ file via g++:

{
"version": "2.0.0",
"tasks": [
    {
        "label": "echo",
        "type": "shell",
        "command": "g++",
        "args": [
            "-I ~/vcpkg/installed/x64-osx/include/",
            "test.cpp"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]
}

The problem is the resulting command > Executing task: g++ '-I ~/vcpkg/installed/x64-osx/include/' test.cpp < has single quotes so that won't work.

I took a look here and tried this:

{
"version": "2.0.0",
"tasks": [
    {
        "label": "echo",
        "type": "shell",
        "command": "g++",
        "args": [
            {
              "value": "-I ~/vcpkg/installed/x64-osx/include/",
              "quoting": "escape"
            },
            "test.cpp"
          ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]
}

The problem is the resulting command> Executing task: g++ -I\ ~/vcpkg/installed/x64-osx/include/ test.cpp < uses escape so has a \.

How can I generate the desired command:

g++ -I ~/vcpkg/installed/x64-osx/include/ test.cpp

Dharman
  • 30,962
  • 25
  • 85
  • 135
Dave Chambers
  • 2,483
  • 2
  • 32
  • 55

1 Answers1

0

The single quotes are added because there is a space in the argument. Just make "-I" and "~/vcpkg/installed/x64-osx/include/" separate args.

"args": [
    "-I", "~/vcpkg/installed/x64-osx/include/",
    "test.cpp"
]
Steve
  • 1