参数中带有双引号的 Visual Studio Code launch.json runtimeArgs

Ste*_*ess 6 json visual-studio-code

我正在运行带有 'Debugger for Chrome' 扩展的 Visual Studio Code 来调试一些 javascript。但是,我想在调试时运行一个进程外的胡椒插件。

在 Visual Studio Code 之外,我们通过将以下命令行标志传递给 chrome.exe(以及其他)来做到这一点:

--register-pepper-plugins="path_to_plugin";mime_type
Run Code Online (Sandbox Code Playgroud)

注意:需要双引号

为了通过 Visual Studio Code 将命令行参数传递给 Chrome,我设置了一个 launch.json 并添加以下内容:

"runtimeArgs" : ["--register-pepper-plugins=\"path_to_plugin\";mime_type"]
Run Code Online (Sandbox Code Playgroud)

我可以使用 ProcessExplorer 看到我的 runtimeArgs 被传递给 Chrome,但转义字符 \ 完好无损,所以 chrome 实际收到的是:

--register-pepper-plugins=\"path_to_plugin\";mime_type
Run Code Online (Sandbox Code Playgroud)

而不是

--register-pepper-plugins="path_to_plugin";mime_type
Run Code Online (Sandbox Code Playgroud)

如果我删除转义字符,我只会得到

--register_pepper_plugins=
Run Code Online (Sandbox Code Playgroud)

因为第二个双引号匹配第一个。

我在这里做了一些明显明显的错误吗?

Sen*_*nel -8

做到这一点的方法是使用反冲来转义额外的引用,例如:

{
"version": "0.2.0",
"configurations": [
    {
        "name": "Launch",
        "type": "go",
        "request": "launch",
        "mode": "exec",
        "remotePath": "",
        "port": 2345,
        "host": "127.0.0.1",
        "program": "C:\\Geth\\gs\\bin\\geth.exe",
        "env": {},
        "args": ["--datadir",
             "/tmp/eth/60/01" ,
            "--verbosity",
            "9",
            "--nodiscover", 
            "--bootnodes",
            "enode://c50f8c5a50b898ab66231754855c582548ce722311e73c5e664a563ff35d8bddb26c10c74c2ebe62c69c6c7ed00031ef3e2d7fd563ff77cff91775cd3f07e4c3@[::]:30301",  
            "--ipcdisable",
            "--port",
            "30303", 
            "--rpcport",
            "8101",
            "console 2"],
        "showLog": true
    }
]
Run Code Online (Sandbox Code Playgroud)

}

  • 一个非常糟糕的答案。您的示例没有转义引号,甚至没有runtimeArgs。此外,问题清楚地表明OP已尝试正常转义。 (2认同)