'How can I configure this code to use a file name with space(ie: hello world.c ) in Vs code terminal? I mean where is the error here?

Windows 11|| Vs Code version 1.67.1.0 || Power Shell 7.2.3

I have a filename with a space in it like hello world.c, and I want to compile this from VSCode.

The relevant section of my tasks.json file is:

    {
        "type": "shell",
        "label": "Run C",
        "command": "C:\\msys64\\mingw64\\bin\\gcc.exe -g3 -Wall \"${file}\" -o \"${fileDirname}\\${fileBasenameNoExtension}.exe\" &&\"${fileDirname}\\${fileBasenameNoExtension}.exe\"",
        "options": {
            "cwd": "${fileDirname}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "detail": "compiler: C:\\msys64\\mingw64\\bin\\gcc.exe"
    }

However, this fails to compile as the filename is not correctly escaped on the command line.

How can I modify the command to ensure that the filename is correctly escaped for the compiler?

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source